Allowing Users to Edit Item Labels

To allow users to edit the item labels, the treeview control should be created with the TVS_EDITLABELS style. Either you can set this style in the resource editor, or in the call to Create() or in PreCreateWindow() if you are using the CTreeView class.

You should then handle the TVN_BEGINLABELEDIT and the TVN_ENDLABELEDIT notifications. You can use the class wizard to add the handler functions. Actually it is not necessary to handle the TVN_BEGINLABELEDIT notification but it is a good idea to do so and limit the length of the text that the user may enter into the edit control.

void COutline::OnBeginLabelEdit(NMHDR* pNMHDR, LRESULT* pResult)
{
   TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;

   // Limit text to 127 characters
   GetEditControl()->LimitText(127);

   *pResult = 0;
}

It is necessary for you to handle the TVN_ENDLABELEDIT notification. If you don't do so, then although the user will be able to edit the labels, but at the end of the edit the value of the label will be set to the previous value. The handler is also a good place to update any internal data structure you maintain to track the state of the tree view control.

void COutline::OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult)
{
   // Set result to TRUE to accept the changes
   *pResult = TRUE;
}

IT Offers

Comments

  • Jordan shoes mentioned Gene to go for the discredit, a segment of Nike

    Posted by TaddyGaffic on 04/24/2013 07:22pm

    Where did that get us? A bunch of banks writing loans that they didnt care if poeple would be able to pay for because they were conforming [url=http://markwarren.org.uk/goodbuy.cfm]nike free[/url] loans and Fannie and Freddie would back them. And their $150+ billion losses show that they are just as unable to predict or control the market as the rest of us. It won't work because it doesn't reward investors for taking the risks involved. In order to set a good example of following your dreams, you may wish to consider strictly limiting, or eliminating TV from your life. When people are involved in pursuing their dreams they often find that they do not have the time to watch TV. TV just gets in the way of pursuing other dreams.. Take a limousine ride with Aerosmith on one of the fastest rollercoaster you have to face. Live shows throughout the day from Beauty and the Beast [url=http://northernroofing.co.uk/roofins.cfm]nike free run 3[/url] will bring memories flooding back for young and old. You can get closer to the action and feel that he wanted to be in the spotlight. Other technology advancements are the midsole. It has a compression molded EVA for lasting impact protection. A Vibrakill shock-absorber in the heel provides a lot of [url=http://markwarren.org.uk/property-waet.cfm]air max 90 uk[/url] comfort, and the Exact Pro technology combines a pebax plate and a Dynamic camflex in the forefoot for improved energy return on every step. Meindl Borneo Lady Pro - This shoe is just one of my wifes most popular hiking boots. It is appropriate for lengthy outdoor hikes and you can actually do a tiny stretch of hill hiking whilst sporting them. This product also includes memory foam

    Reply
  • Tree Control in a dialog - Win32

    Posted by SLyons on 05/26/2004 10:23am

    I created a tree control in a dialog box in Win32. I prevent editing returning TRUE from TVN_BEGINLABELEDIT. The selection highlighting on the entry disappears. Clicking on the entry again won't work until a different entry has been selected. Has anybody got any ideas about how to get round this problem. Simon

    Reply
  • Restricting editing

    Posted by Legacy on 10/23/2002 12:00am

    Originally posted by: Simon

    It there a possibility to allow edit only some items and the others not?

    I would like to edit only (in my application) red items, but blue should be fixed and not possible to edit. Is that possible just with graying the choices on the menu, but what is if the user will try to edit label just with left click on text.

    Thanks.

    Reply
  • Does't work for TreeCtrl inDialog box.

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

    Originally posted by: Srini

    Yes, It did not.

    Reply
  • Example worked a treat for me, but how do I force a refresh of callback text?

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

    Originally posted by: hal9000lives

    Hi there,

    The web-page explanation was more than enough for me to get it working in a CTreeView.

    One problem: My text comes from LPSTR_TEXTCALLBACK's and the strings are not requested again through the OnGetDispInfo, so the display does not change even though my data does.

    How do I tell the tree to refresh an item's text?

    Thanks

    Reply
  • Does not seem to work when TreeCtrl in a view...

    Posted by Legacy on 07/31/2001 12:00am

    Originally posted by: Fred

    Edit label box never appears...

    Reply
  • Editing label

    Posted by Legacy on 06/05/2001 12:00am

    Originally posted by: shinilkp

    if u could givean example of editing using TVN_ENDLABELEDIT

    Reply
  • It is diffcult to edit label accroding with this sugestion

    Posted by Legacy on 08/14/2000 12:00am

    Originally posted by: szChen

    /*The Following are My Codes*/
    
    void CViewTree::OnBeginlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
    {
    TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
    // TODO: Add your control notification handler code here

    CTreeCtrl& cThisTree = GetTreeCtrl();
    cThisTree.GetEditControl()->LimitText(127);

    *pResult = 0;
    }

    Reply
  • How do I have RichEdit Labels in a TreeView/TreeControl

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

    Originally posted by: Mark

    Is there any way I can have RichEdit Labels in a TreeView.
    Any help would be appreciated.
    Thanks
    Mark

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

Go Deeper

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds