Answered by:
Click Event for Nodes on Treeview VB.NET

Question
-
I have a treeview that is a navigation of all the forms in my application ... how do i have to code so that when a node is clicked it will display show to programmed code.
Example > Customer > Add New > View/Edit If Add New was clicked, it would show the New Customer Screen etc. etc.
- Changed type Justin Adkins Thursday, December 16, 2010 10:02 PM
Tuesday, November 9, 2010 1:01 AM
Answers
-
Hi,
I think you can handle nodemouseclick event. Like Follows:
Private Sub treeView_NodeMouseClick(ByVal sender As Object, ByVal e As TreeNodeMouseClickEventArgs) If e.Node.Text.Equals("Add New") Then 'add new custom; End If If e.Node.Text.Equals("View/Edit") Then 'codes End If End Sub
Hope it helps.
Sincerely,
Vin Jin
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.- Marked as answer by Justin Adkins Thursday, December 16, 2010 10:02 PM
Wednesday, November 10, 2010 7:34 AM
All replies
-
Hi,
I think you can handle nodemouseclick event. Like Follows:
Private Sub treeView_NodeMouseClick(ByVal sender As Object, ByVal e As TreeNodeMouseClickEventArgs) If e.Node.Text.Equals("Add New") Then 'add new custom; End If If e.Node.Text.Equals("View/Edit") Then 'codes End If End Sub
Hope it helps.
Sincerely,
Vin Jin
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.- Marked as answer by Justin Adkins Thursday, December 16, 2010 10:02 PM
Wednesday, November 10, 2010 7:34 AM -
Private Sub TreeView1_NodeMouseClick(ByVal sender As Object, ByVal e As TreeNodeMouseClickEventArgs) If e.Node.Name.Equals("CusAddNew") Then Dim frm As New NewCustomer frm.MdiParent = DIS frm.Show() End If This is the code i inserted and nothing happens when the node is clicked ... I changed it a little form e.Node.Text.Equals to e.Node.Name.Equals
Sunday, December 12, 2010 3:09 PM -
Sub isn't handling any event, you're missing the Handles part.
Private Sub treeView_NodeMouseClick(ByVal sender As Object, ByVal e As TreeNodeMouseClickEventArgs)
Should be
Private Sub treeView_NodeMouseClick(ByVal sender As Object, ByVal e As TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseClick
However, if you're adding nodes in Run time, you'll have to add handler in run time as well
AddHandler treeNodeToBeAdded.MouseClick, AddressOf treeView_NodeMouseClick
Thanks
A place for MSDN users to socialize
Living on Earth may be expensive, but did you know that it includes a free trip around the sun? Isn't that worth it?Sunday, December 12, 2010 3:40 PM -
I feel soooo dumb lol
i didn't even notice that!
Thanks!
Tuesday, December 14, 2010 1:29 AM