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 window).
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.
 



Comments

  • How About CListCtrl

    Posted by Legacy on 05/15/2003 12:00am

    Originally posted by: yanwj

    (poor english)
    I use CListCtrl instead of CListView,I set the LVS_EDITLABELS,but it not work ,how?Thanks

    Reply
  • Thanks

    Posted by Legacy on 04/21/2003 12:00am

    Originally posted by: Mike

    This saved me tons of time. The MFC leaves much to be desired

    Reply
  • Ok

    Posted by Legacy on 04/15/2003 12:00am

    Originally posted by: Rodrigo Cansian

    OK, funcionou uma maravilha, muito bom o c�digo

    :)

    Reply
  • Enter key stopped working

    Posted by Legacy on 05/04/2002 12:00am

    Originally posted by: Fuse

    I had label editing working perfectly but for some reason the ENTER key no longer functions while in edit mode. All else is normal. Anyone have an idea why this might be so?

    Reply
  • Endlabel edit problem

    Posted by Legacy on 01/30/2002 12:00am

    Originally posted by: Eleven

    I have the same problem that Moshe had.
    When a Label is in edit mode. And I click the mouse button
    within it. I get an Access Violation from comctl32.dll.
    It does not Happen when I press Enter or Click outside.I
    have tried 'most everything in OnEndLabelEdit.
    Any Ideas? Thank

    Reply
  • How can I select item in this function?

    Posted by Legacy on 01/11/2002 12:00am

    Originally posted by: yu

    I want to check the input in OnEndLabel() function. If the input is wrong, I hope to select the current item and input again. I use SetItemState(nItem, LVIS_SELECTED | LVIS_FOCUSED ,LVIS_SELECTED|LVIS_FOCUSED );

    but it does not work. The case is like you rename a folder name to a existing folder in Windows Explorer. How can I still keep focus on the editing item.

    Reply
  • Is there a way to edit subitems?

    Posted by Legacy on 11/08/2001 12:00am

    Originally posted by: Miguel Lopes

    Is there a way to edit subitems without using CEdit control on top of it, only using CListCtrl functions?

    Reply
  • Problem with LVN_BEGINLABELEDIT

    Posted by Legacy on 08/15/2001 12:00am

    Originally posted by: Damir Suban

    LVN_ENDLABELEDIT works fine for me, but I have a problem when I do not want to allow editing some labels. I don't want to even start the editing process, when user clicks on some labels. I have read that I have to return TRUE in respond to the LVN_BEGINLABELEDIT, but this does not work. Any suggestions?

    Reply
  • Prroblem with EndLabelEdit

    Posted by Legacy on 12/10/2000 12:00am

    Originally posted by: Moshe

    When a Label is in edit mode. And I click the mouse button within it. I get an Access Violation from comctl32.dll.
    It does not Happen when I press Enter or Click outside.I have tried 'most everything in OnEndLabelEdit.
    Any Ideas? Thank

    Reply
  • "Reflected" message?

    Posted by Legacy on 05/29/2000 12:00am

    Originally posted by: Don Stauffer

    Can you elaborate? I'm trying to understand why the ListView handles the LVN_ENDLABELEDIT message even though the message was sent to the parent of the ListView.

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: August 20, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT When you look at natural user interfaces as a developer, it isn't just fun and games. There are some very serious, real-world usage models of how things can help make the world a better place – things like Intel® RealSense™ technology. Check out this upcoming eSeminar and join the panel of experts, both from inside and outside of Intel, as they discuss how natural user interfaces will likely be getting adopted in a wide variety …

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds