TreeView and TreeNodes

J

jp2msft

My first time using a TreeView:

I've got a TreeView that I populated with some data and it has nodes.

In the Properties window, I created an Event Handler for the TreeView's
AfterSelect method, and it allows me to determine what Tree Node has been
selected.

However, if I expand the TreeView and select one of the Child TreeNodes,
they do not trigger this event.

My local help says to use the SelectedNodeChanged Event, but I do not see
that in the Properties window.

How is the best way to handle whenever an item in my TreeView is selected
(including the TreeView TreeNodes)?

Thanks,
Joe
 
K

kimiraikkonen

My first time using a TreeView:

I've got a TreeView that I populated with some data and it has nodes.

In the Properties window, I created an Event Handler for the TreeView's
AfterSelect method, and it allows me to determine what Tree Node has been
selected.

However, if I expand the TreeView and select one of the Child TreeNodes,
they do not trigger this event.

My local help says to use the SelectedNodeChanged Event, but I do not see
that in the Properties window.

How is the best way to handle whenever an item in my TreeView is selected
(including the TreeView TreeNodes)?

Thanks,
Joe

As i understood, you created an AfterSelect event for TreeView
control, i couldn't reproduce the problem about triggering AfterSelect
event, here it is:

Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal
e As System.Windows.Forms.TreeViewEventArgs) Handles
TreeView1.AfterSelect
MsgBox("worked!")
End Sub

..which works even when a root or child node is selected.

Plus, there's no an event called "SelectedNodeChanged" for TreeView as
i'm using .NET 2.0 for "Winforms", based on my search it's available
for ASP.NET web controls and though i referenced System.Web.dll and
imported "System.Web.UI.WebControls" still i'm unable to get
"SelectedNodeChanged" event maybe due to using VB 2005 express instead
of Visual Web Developer.

Plus, you can check this out for usage:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treeview.selectednodechanged.aspx

Hope this helps,

Onur Güzel
 
J

jp2msft

Interesting. You are right! It is working today.

Perhaps I had a bug in the system yesterday. Sorry for the confusion.
 

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