TreeView - Fire AfterLabelEdit Event

Posted on 2004-08-11
Last Modified: 2008-01-09
With VB6 and the TreeView control,

Is it possible to fire the AfterLabelEdit event even when the node label was not changed?

(While editing a label, if the user presses Enter without making any change to the label, or if simply clicks elsewhere, AfterLabelEdit is not fired.)
Question by:campinas
  • 4
  • 2
LVL 22

Assisted Solution

DarkoLord earned 100 total points
ID: 11771729
You could subclass a treeview to recieve all messages... if you don't want to do that we'll find a different solution...


Author Comment

ID: 11771843
Then I'd have to change a lot of code.. What would be the other solution?
LVL 19

Accepted Solution

arif_eqbal earned 400 total points
ID: 11772107
Well If a user starts Editing of a Label and without changing the original text comes out of editing mode then the AfterLabelEdit event is not fired. If this is your problem then you can use a bit of trick.

Declare a form level variable say EditStart
on BeforeLabelEdit event set it to True, i.e once the user starts editing we set this flag. Now in order to cancel this edit he will have to click somewhere, Now trap the LostFocus and Click event of TreeView and check if your Flag is True or not If it is then call your AfterlabelEdit event function.

In case you need a working code I can write it for you just post back here.
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.


Author Comment

ID: 11775834
Thank you !  It's clear for me... I'll probably have to add the  check for Enter too.
LVL 22

Expert Comment

ID: 11775885
Hi again,
I tried that what arif_eqbal said even before posting my first message but I couldn't get keyboard event to fire, because when you press the key while editing, the key is actually not pressed in a treeview but in a textbox that you type into...

good luck!

Author Comment

ID: 11775963

Author Comment

ID: 11776015
Then maybe forcing AfterLabelEdit is not really a practical idea...

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

809 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