CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2005
    Location
    Madrid (Spain)
    Posts
    511

    Editing subitems of CListCtrl

    Hi gurus.

    How can I edite the subitems of a CListCtrl?? I only can edit the first value (first colum).


    Thanks in advance
    Last edited by juanpast; October 3rd, 2007 at 03:46 AM.

  2. #2
    Join Date
    Sep 2003
    Posts
    213

    Re: Editing subitems of CListCtrl

    You can use CListCtrl::SetItemText

    eg.
    Code:
    mListCtrl.setItemText( 2, 4, "yourString" );
    Its trying to set the text at, Row 3, Column 5, to become "yourString".
    Assuming that the row number and column number really exist.

    If you need to set other variables other than text of the subitem, then you have to use CListCtrl::GetItem and populate the LVITEM structure properly to retrieve their attributes. Then a call to CListCtrl::SetItem to save the changes that you have made.
    Last edited by justin0108; October 3rd, 2007 at 04:16 AM.

  3. #3
    Join Date
    Feb 2005
    Location
    Madrid (Spain)
    Posts
    511

    Re: Editing subitems of CListCtrl

    Thanks, but I not explain well....


    when you have a subitem into a view and you want to edit clicking over the text. It is possible with the first item but no in subitems....

    How I can edit (clicking over the text) the subitems??

  4. #4
    Join Date
    Feb 2000
    Location
    Indore, India
    Posts
    1,046

    Re: Editing subitems of CListCtrl

    Hello,

    It is not possible to edit the subitems of the listbox. You can edit the selected item in a combobox. But with some coding, you can edit the item in a listbox also.

    Since clicking results in selecting an item in listbox, you need another event to start editing, like left button double click or middle button click. On that event, create an edit box spanning the rectangle of that item in listbox. In the event of selection change, delete the edit box after copying the string as the item of the list box.

    I am thinking of writing this method as a FAQ, which you may refer once it is accepted.

    Regards,
    Pravin.
    Let me know if I have helped by rating this post

    Recent FAQs

    Drag an image
    Area of a window exposed on desktop
    Display rotated bitmap

  5. #5
    Join Date
    Feb 2005
    Location
    Madrid (Spain)
    Posts
    511

    Re: Editing subitems of CListCtrl

    It is possible to obtain the pointer of the editbox? and if it is true we can modify the text....

    Derivating the CListCtrl, we can obtain the list of the editbox??

    I think it is better to wait for found a good solution to write this in FAQs...


    Thanks

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Editing subitems of CListCtrl

    While you can't edit the subitem text directly, you can 'overlay' an edit box over the subitem and essentially get the same functionality. Using this technique you can also edit via an edit box, drop list combo box or some other control. Check out the LVEdit.Zip sample found in this post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured