473,385 Members | 1,409 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,385 software developers and data experts.

What's the best way to handle multiple contextmenus in treeview?

I want to display different menu item options depending on what the user
right-clicks on the tree. I cant figure out how though,

I currently tried to create separate ContextMenu objects in a class which
inherits from TreeView, and then in it's MouseClick event I do:

protected override void OnMouseClick(MouseEventArgs e)
{
TreeNode node = this.GetNodeAt(e.Location);
this.SelectedNode = node;

if (something)
menu1.Show(this, e.Location);
else
menu2.Show(this, e.Location);
}

where menu1 and menu2 both initialized in constructor like this (copy for
menu2):

menu1 = new ContextMenu();
menu1 .MenuItems.Add(renameItem);
menu1 .MenuItems.Add(deleteItem);

All that happens when I right-click is I select the node, but no context
menu ever appears! What's the proper way to do this?
Oct 26 '06 #1
0 1124

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

Similar topics

0
by: Martin Russ | last post by:
Hi, Although this is in VB.NET, I don't believe it's language specific. I have an application that has several panes (similar to Visual Studio in the Solution Explorer - Solution, Search,...
3
by: Hazz | last post by:
I am just beginning to design a Treeview display (winforms) for wine regions. Problem. Some wine growing regions belong to two counties. Eg. Carneros is in both Napa and Sonoma Counties. Although...
3
by: Grant Schenck | last post by:
Hello, I'm going round and round on how to best handle images for a treeview control. These are all known at design time so there is no dynamic aspect. That said, I want to associate the...
2
by: Guy Lafleur | last post by:
I have a user control that builds a treeview dynamically in the Page_Load event. Also, I have the AutoEventWireup property set to true (i.e., <%@ Control AutoEventWireup="true" %>). Then, when I...
1
by: Juan Romero | last post by:
Hey guys, I have a small problem here.... I have a treeview control. I want to display a popup menu when the user right clicks on a node. This is no problem, and I am able to make the popup come...
2
by: engwar1 | last post by:
I'm a .Net newbie and have started writing a Windows Forms application to assist me in choosing files/directories to move from one drive to another. Basically what I want is something like the...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
1
by: Wing Siu | last post by:
Dear All I faced this problem. I knew Microsoft has published a WebControl, which included TreeView, but it sees not my cup of team since it cannot handle onmousedown or onmouseup. Do I need...
1
by: Jeff | last post by:
Hey I'm about to start developing an windows application based on .net 2.0. The GUI will consist of 2 things: a treeview and an area displaying things based on selections in the treeview. The...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...

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.