Solved

Allowing user editing on CTreeCtrl

Posted on 1998-10-01
6
436 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
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

785 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