473,699 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Mo useEventArgs e)
{
TreeNode node = this.GetNodeAt( e.Location);
this.SelectedNo de = 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 1137

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

Similar topics

0
1062
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, Dynamic Help, Properties) etc. One on of my panes there is a TreeView control. I'm reading XML into this TreeView perfectly - regardless of whether the TreeView is visible or not.
3
2566
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 most nodes will have only one parent, a few will have two parents. The Treeview which seems to me to lend itself to the Windows Explorer type of app could not possibly show one file as a leaf belonging to two different parent folders. You either...
3
2583
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 image with my project so I can easily edit them. It seems like I need to do this: - Create one bitmap per image.
2
406
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 'run' the application, I get two treeviews instead of one. I'm thinking this is because of the AutoEventWireup property being set to true. 1. Am I correct? If so, if the AutoEventWireup property is true, why does it create two treeview in my user...
1
2117
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 out. However, when I want to perform an operation based on the node selected, I find that the node actually gets selected after the popup goes away. In other words, if I right click a random item in the treeview and the user selects an...
2
1620
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 TreeView control and have the following questions. + I'm not sure if it's possible to include a checkbox control as part of a TreeView. Do I need to use images of a checkbox in my ImageIndex property? I'd imaging I'd need 4 images of directories...
9
3190
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 load with different data (locations, departments, etc.).
1
1328
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 write my CustomControl? Or any other solution? Thanks
1
1298
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 treeview shows all the modules in the application and gives easy access to each module... Lets say I today have 5 modules I want to include in this application. But some day in the future I may have more modules in the application....
0
9033
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
8911
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
8882
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7748
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
6533
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
5872
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
4375
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...
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2345
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.