473,790 Members | 2,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Treeview - different context menus for different nodes

Hi - I've seen quite a few posts that almost match this but haven't
found a solution that works.

I have an explorer-like application with a treeview in the lefthand
pane. When I right-click on a node, a context menu appears. How can I
get different context menus to appear depending on which node is
chosen. Here's my existing code:

Private Sub treeView1_Mouse Down(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles TreeView1.Mouse Down

If e.Button = MouseButtons.Ri ght Then
TreeView1.Selec tedNode = TreeView1.GetNo deAt(e.X, e.Y)
Dim ClickPoint As Point = New Point(e.X, e.Y)
Dim ClickNode As TreeNode =
TreeView1.GetNo deAt(ClickPoint )
If ClickNode Is Nothing Then

Return

End If

' Show context menu

ContextMenu1.Me nuItems.Clear()

ContextMenu1.Me nuItems.Add("Ad d " &
TreeView1.Selec tedNode.Text, New EventHandler(Ad dressOf
menuItemAdd_Cli ck))

ContextMenu1.Me nuItems.Add("De lete " &
TreeView1.Selec tedNode.Text, New EventHandler(Ad dressOf
menuItemDelete_ Click))

ContextMenu1.Sh ow(TreeView1, clickpoint)
End If
Nov 21 '05 #1
1 1441
Can you use the node.tag property to somehow
identify the type of node clicked and then create the
contect menu based on that.

On 24 Aug 2004 10:08:16 -0700, ro****@hotmail. com (Rory) wrote:
Hi - I've seen quite a few posts that almost match this but haven't
found a solution that works.

I have an explorer-like application with a treeview in the lefthand
pane. When I right-click on a node, a context menu appears. How can I
get different context menus to appear depending on which node is
chosen. Here's my existing code:

Private Sub treeView1_Mouse Down(ByVal sender As Object, ByVal e As
System.Windows .Forms.MouseEve ntArgs) Handles TreeView1.Mouse Down

If e.Button = MouseButtons.Ri ght Then
TreeView1.Selec tedNode = TreeView1.GetNo deAt(e.X, e.Y)
Dim ClickPoint As Point = New Point(e.X, e.Y)
Dim ClickNode As TreeNode =
TreeView1.GetN odeAt(ClickPoin t)
If ClickNode Is Nothing Then

Return

End If

' Show context menu

ContextMenu1.Me nuItems.Clear()

ContextMenu1.Me nuItems.Add("Ad d " &
TreeView1.Sele ctedNode.Text, New EventHandler(Ad dressOf
menuItemAdd_Cl ick))

ContextMenu1.Me nuItems.Add("De lete " &
TreeView1.Sele ctedNode.Text, New EventHandler(Ad dressOf
menuItemDelete _Click))

ContextMenu1.Sh ow(TreeView1, clickpoint)
End If


Nov 21 '05 #2

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

Similar topics

0
1003
by: Rory | last post by:
I have an app that populates a treeview from an XML file. I want to create a few different context menus that pop up depending on which node is selected. I can get one context menu to appear when I right click a node but when I try to add code to check the node and then choose the appropriate context menu nothing happens. The following is a code snippet I'm using: Select Case clicknode.text Case "Apples" ContextMenu1.Show(TreeView1,...
4
1285
by: alanrn | last post by:
I am using a TreeView to display the hierarchy of a strongly-typed collection (inherited from CollectionBase). The order of the nodes in the TreeView is strictly tied to the order in which they appear in the underlying collection. However, the user must be able to reorder certain items in the collection--and, hence, the TreeView. I have created a context-sensitive menu that allows the user to move an item in the collection either up or...
2
4577
by: Trond Hoiberg | last post by:
Let say i have a bunch of files. Logfiles that is stored in subfolders. Folder1 --logfile1 --logfile2 --logfile3 Folder2 --logfile1 --logfile2 I want to display these files using data from the files in an TreeView
5
9501
by: Dotnet Gruven | last post by:
With this TreeView declaration: <asp:TreeView ID="Cloner" runat="server" SelectedNodeStyle-Font-Bold="true" SelectedNodeStyle-ForeColor="#003E21" OnTreeNodePopulate="PopulateNode" OnSelectedNodeChanged="SelectNode" ExpandDepth="0">
4
1382
by: Martin | last post by:
I have a treeview control, which is docked on a panel. When I call the procedure to fill this treeview from the load event it works fine. It loads all nodes, and displays them nicely. However, when I call the very same procedure at a later stage (after a login) then the nodes don't show. I traced with the debugger, and the nodes do get created, but when I check the IsVisible property, it is set to No. So, now comes the weirdest part......
4
6374
by: John Dann | last post by:
I'm trying to implement a fairly simple Treeview procedure but running into problems. My Treeview has just two levels of nodes: top-level and one child level. I want a doube-click on the Treeview to do one of two things: If the double-click was on a top-level node then the default action of exapnding/collapsing the node should be allowed as usual and with no further action.
6
2610
by: serge calderara | last post by:
Dear all, I was wondering is there is a way to customise the treView control in order to get any Control as a Node. What I try to do is having a Progress bar as a treeview node object. Is that possible ? regards serge
2
1558
by: casManG | last post by:
I am working on a small project that uses the treeview control in .net 2003. I have a tree view that I am sending to a sub in order to iterate through the nodes. Public Sub test (ByVal inTreeView as Tree View) But, the thing I want to do with the inTreeView requires me to expand all the nodes before I iterate. The problem is that when the sub is complete, the original tree view on my form ends up with all of the nodes expanded I had...
0
3314
by: divya1949 | last post by:
Create a windows c# application which will Read a xml file and populate nodes in the treeview. 1 On selection of treenode display the child nodes of that node in listview control 2. Provide following view properties to listview, through View menu a. Tile b. Icon
0
10200
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7530
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.