473,395 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

TreeView And ContextMenu Question

Hi Everyone,

i have a treeview that look like this.

Node1
nodechild1.1
nodechild1.2
nodechild1.3
Node2
nodechild2.1
nodechild2.2

and so on

and i would like to bind one contextmenu to the root nodes (Node1, Node2)
and other contextmenu to the Childs.

how can i do that ?

Thanks,

T :-)
Nov 21 '05 #1
2 1313
* "Tiraman :-\)" <ti*****@netvision.net.il> scripsit:
i have a treeview that look like this.

Node1
nodechild1.1
nodechild1.2
nodechild1.3
Node2
nodechild2.1
nodechild2.2

and so on

and i would like to bind one contextmenu to the root nodes (Node1, Node2)
and other contextmenu to the Childs.


\\\
Private Sub TreeView1_MouseUp( _
ByVal sender As Object, _
ByVal e As MouseEventArgs _
) Handles TreeView1.MouseUp
If e.Button = MouseButtons.Right Then
Dim n As TreeNode = Me.TreeView1.GetNodeAt(e.X, e.Y)
If Not n Is Nothing Then
Me.TreeView1.SelectedNode = n
Me.MenuItem1.Text = n.Text
Else
Me.MenuItem1.Text = "(no item selected)"
End If
Me.ContextMenu1.Show(Me.TreeView1, New Point(e.X, e.Y))
End If
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2
Thanks!

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eg**************@TK2MSFTNGP15.phx.gbl...
* "Tiraman :-\)" <ti*****@netvision.net.il> scripsit:
i have a treeview that look like this.

Node1
nodechild1.1
nodechild1.2
nodechild1.3
Node2
nodechild2.1
nodechild2.2

and so on

and i would like to bind one contextmenu to the root nodes (Node1, Node2) and other contextmenu to the Childs.


\\\
Private Sub TreeView1_MouseUp( _
ByVal sender As Object, _
ByVal e As MouseEventArgs _
) Handles TreeView1.MouseUp
If e.Button = MouseButtons.Right Then
Dim n As TreeNode = Me.TreeView1.GetNodeAt(e.X, e.Y)
If Not n Is Nothing Then
Me.TreeView1.SelectedNode = n
Me.MenuItem1.Text = n.Text
Else
Me.MenuItem1.Text = "(no item selected)"
End If
Me.ContextMenu1.Show(Me.TreeView1, New Point(e.X, e.Y))
End If
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Peter Zentner | last post by:
Hi all, if I assign a context menu to a treeview and popup the contextmenu with the APP-key the context menu appears in the center of the treeview control and not at the selected treenode. Is...
4
by: Aaron Queenan | last post by:
How can I use the designer to add a context menu to a class which inherits from a control, e.g. treeview, without adding the context menu to a form? For example, to add a context menu with...
7
by: Michael C | last post by:
Hi all, I half-resolved my previous TreeView issue. Now I was wondering if anyone knows of a way to keep a TreeNode from being highlighted when it is left-clicked? It seems like there should...
1
by: Shailendra Batham | last post by:
Hey guys I am using the IE Web controls treeview control. I popuplate the treeview with XML and it looks fine........... my question is how can I add a right click popup menu to the treeview...
3
by: vijaynats | last post by:
I have a treeview with a ContextMenu attached. When i click on a node, AfterSelect fires but does not fire when right clicked (the context menu pops up). (Background: I have loaded a list of...
5
by: A-PK | last post by:
Hi, I am using treeview as my menu. my menu is like the following + Users & Groups - Users -Groups + Departmenuts - Engineering
1
by: Joerg Trumpfheller | last post by:
Hey people, how can I select a treenode with the MouseButtons.Right event if there is no contextmenu? I build up a treeview with 3 levels. Only if the second level is selected, there should...
1
by: Chris Murphy via DotNetMonster.com | last post by:
Hi all, I'm just wondering if any one can help me with this development issue I'm having. I've created a customized treeview control to handle the particular tasks to which I'll be using it. Within...
3
by: sugee | last post by:
hi, I have a treeview when rightclicked a context menu should appear. but first time wen i right click the context menu of that node(ie, add,delete) appears whereas when i right click another...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.