| | |
Treeview + Small Probs
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Apr 2009
Posts: 33
Reputation:
Solved Threads: 1
I have a treeview with two nodes..I m showing the contextmenu when the user clicks on any portion of treeview ....
Mine probs is that when i right click on Second Child,Contextmenu is showing....But aotomatically root is selected....Y....?Plz copy this code,U will get to know what i want to ask!!!!!!!!!!!
VB.NET Syntax (Toggle Plain Text)
Public Class Form2 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Dim N As New TreeNode() Me.TreeViewCategories.Nodes.Clear() With Me.TreeViewCategories.Nodes N = .Add("", "Main", 0) N.Nodes.Add("", "First Child", 0) N.Nodes.Add("", "Second Child", 0) End With TreeViewCategories.ExpandAll() Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub TreeViewCategories_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeViewCategories.MouseDown If e.Button = Windows.Forms.MouseButtons.Right Then ContextMnuTreeview.Show(TreeViewCategories, e.X, e.Y) End If End Sub
Mine probs is that when i right click on Second Child,Contextmenu is showing....But aotomatically root is selected....Y....?Plz copy this code,U will get to know what i want to ask!!!!!!!!!!!
•
•
•
•
I have a treeview with two nodes..I m showing the contextmenu when the user clicks on any portion of treeview ....
VB.NET Syntax (Toggle Plain Text)
Public Class Form2 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Dim N As New TreeNode() Me.TreeViewCategories.Nodes.Clear() With Me.TreeViewCategories.Nodes N = .Add("", "Main", 0) N.Nodes.Add("", "First Child", 0) N.Nodes.Add("", "Second Child", 0) End With TreeViewCategories.ExpandAll() Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub TreeViewCategories_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeViewCategories.MouseDown If e.Button = Windows.Forms.MouseButtons.Right Then ContextMnuTreeview.Show(TreeViewCategories, e.X, e.Y) End If End Sub
Mine probs is that when i right click on Second Child,Contextmenu is showing....But aotomatically root is selected....Y....?Plz copy this code,U will get to know what i want to ask!!!!!!!!!!!
VB Syntax (Toggle Plain Text)
TreeView1.Nodes.Add("Root") TreeView1.Nodes(0).Nodes.Add("Work") TreeView1.Nodes(0).Nodes.Add("Play") TreeView1.Nodes(0).Nodes(0).ContextMenuStrip = ContextMenuStrip1
Failure is not fatal, but failure to change might be. - John Wooden
•
•
Join Date: Jun 2009
Posts: 234
Reputation:
Solved Threads: 42
If i understood your problem right then this would be the solution
You might raise the TreeViewCategories.NodeMouseClick event to get the current node.
vb Syntax (Toggle Plain Text)
Private Sub TreeViewCategories_NodeMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeViewCategories.NodeMouseClick If e.Button = Windows.Forms.MouseButtons.Right Then TreeViewCategories.SelectedNode = e.Node ContextMnuTreeview.Show(TreeViewCategories, e.X, e.Y) End If End Sub
You might raise the TreeViewCategories.NodeMouseClick event to get the current node.
Last edited by GeekByChoiCe; Jun 14th, 2009 at 3:42 am.
•
•
Join Date: Apr 2009
Posts: 33
Reputation:
Solved Threads: 1
i m able to solved it-
Thx for the help
VB.NET Syntax (Toggle Plain Text)
Private Sub ContextMnuAddColl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContextMnuAddColl.Click Try Dim tnNew As New TreeNode Dim tnSelected As TreeNode tnSelected = TreeViewCategories.SelectedNode If Not tnSelected Is Nothing Then tnNew = tnSelected.Nodes.Add("New Collection") tnNew.EnsureVisible() tnNew.BeginEdit() End If TreeViewCategories.ExpandAll() Catch ex As Exception MsgBox(ex.Message) End Try End Sub
Thx for the help
![]() |
Similar Threads
- FTP Server Directory Treeview (C#)
- Selected node treeview show atrributes in listbox (C#)
- Windows 2000 startup probs (Windows NT / 2000 / XP)
- Java Game Applet Too Small (Java)
- How to Enable ICS on a Home or Small Office Network Connection in Windows XP (Windows tips 'n' tweaks)
- sound card probs mandrake 9.2 (*nix Hardware Configuration)
- small fonts (Web Browsers)
Other Threads in the VB.NET Forum
- Previous Thread: error:40 while creating new SQL Server Database
- Next Thread: how to Deploy an App in VB 2008
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access add application arithmetic array assignment basic binary bing box button buttons click code combobox component connectionstring convert cpu data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists file-dialog firewall folder google hardcopy image images isnumericfuntioncall login math memory mobile module ms msaccess mssqlbackend mysql navigate net networking opacity output peertopeervideostreaming picturebox1 port print printpreview problemwithinstallation project record regex reports" reuse right-to-left save savedialog serial sqldatbase storedprocedure string temp text textbox timer toolbox updown useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet view vista visual visualbasic visualbasic.net visualstudio web wpf xml






