Allowing items to be edited

A list view control has to have the LVS_EDITLABELS style
for it to be editable. This style can be set when creating the control
or even later by using ModifyStyle(). Once we have
set the LVS_EDITLABELS style, the user can set focus on an item and click
on it again to begin editing the item. However, the default behaviour of
the control ignores the changes once the edit is complete. To allow the
edit changes to be accepted, we have to add a handler to the LVN_ENDLABELEDIT
notification. Here is a sample of a reflected message handler (e.i. the
message is handled by the list view control itself, rather than the parent

void CMyListCtrl::OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult)
        *pResult = TRUE;

If we set *pLResult to FALSE, the changes are ignored. Allowing edits of
sub items are not directly supported by the control but can be easily implemented.
It is covered in a different section.


More by Author

Must Read