TreeView Insert Item Event

T

Trecius

Hello, Newsgroupians:

I have a TreeView in a form, and I'd like to be notified when a TreeNode is
inserted into the TreeView. However, I do not see any event that monitors
this action. Can anyone provide some insight as to how I might capture the
insert event? Thank you.


Trecius
 
J

Jeroen Mostert

Trecius said:
I have a TreeView in a form, and I'd like to be notified when a TreeNode is
inserted into the TreeView. However, I do not see any event that monitors
this action. Can anyone provide some insight as to how I might capture the
insert event? Thank you.
As you've discovered, there is no insert event, so you can't capture it
either. Rewrite your code so adding nodes goes through one point and use
that instead. This will also serve you if you need to respond to more
complex changes.

In general, relying on controls to tell you that they've changed
structurally is a no-go in Windows Forms. Control events are mostly
restricted to user interaction, and you should centralize updates yourself.
WPF has a more flexible architecture where the observer model is more
integrated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top