Solved

Allowing user editing on CTreeCtrl

Posted on 1998-10-01
6
439 Views
Last Modified: 2013-11-20
Easy Question:
How to I allow the user to edit the items in a tree control
I have set the window style on creation, but how do I start
the edit process off - so I can receive the messages (start and end edit)?? Has anyone some source for me to look at??
0
Comment
Question by:dd021197
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Expert Comment

by:timop
ID: 1322805
To allow the user to edit the items you must use TVS_EDITLABELS style.

m_treeCtrl.ModifyStyle(0, TVS_EDITLABELS ); // editing is allowed

When label editing begins, a tree view control sends its parent window a TVN_BEGINLABELEDIT notification message.
When label editing is canceled or completed, a tree view control sends its parent window a TVN_ENDLABELEDIT notification message.
0
 
LVL 1

Author Comment

by:dd021197
ID: 1322806
Thanks, the message is now sent. But I still don't understand
how the editing takes place - I want to set it up like explorer
what code do I put where? Do I handle the CEdit control or
is that taken care of. All I have done is set the style on
creation and modified the style. The messages are being called
okay now - but I still can't actually edit the labels.


0
 
LVL 1

Author Comment

by:dd021197
ID: 1322807
The points are yours timop if I can get a bit more info.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:umarama
ID: 1322808
Hi dd !

Handle some mouse or keyboard event (dbl click / Enter /etc) where you wish to activate your editing. Enter the following line

CEdit * pEdit = EditLabel();

CTreeCtrl manages the Edit control. If you wish, you can subclass the edit control in OnBeginLabelEdit() using GetEditCtrl().

Now put code for OnBeginLabelEdit() & OnEndLabelEdit(). You can use GetEditCtrl() to retrieve ptr to this edit control. Use any of the edit controls functions.

Use TV_DISPINFO structure on OnEndLabelEdit to retrieve all sorts of info. Refer documentation. You are responsible for updating the item's label, if appropriate, perhaps after validating the edited string. The pszText member of TV_ITEM is 0 if editing is canceled.

Say what, you should refer to the following documentation.
"Tree Control Label Editing"

If you have any questions regarding Subclassing the edit control, I will gladly help you.
0
 
LVL 2

Accepted Solution

by:
cramer091498 earned 50 total points
ID: 1322809
look at
http://www.codeguru.com/treeview/index.shtml
for a sample solution
0
 
LVL 1

Author Comment

by:dd021197
ID: 1322810
the points are yours

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Detect CR LF to each line 12 176
sum28 challenge 31 117
isEverywhere  challenge 19 86
zeroMAx challenge 20 127
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question