473,473 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Adding a context menu to a treeview

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 "Select All" and "Clear Selection"
to a checked list box?

Thanks,
Aaron Queenan.
Nov 15 '05 #1
4 14157
The only way to add a ContexMenu it's to add the ContexMenu in the Form or
do it in code, or you can add a class that inherits from treeview, and add
the contex menu in your class in the designer.

--
Bela Istok
MVP C#
Caracas, Venezuela
"Aaron Queenan" <aq*********************@contingent.com.au> wrote in message
news:uW*************@TK2MSFTNGP12.phx.gbl...
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 "Select All" and "Clear Selection"
to a checked list box?

Thanks,
Aaron Queenan.

Nov 15 '05 #2
> The only way to add a ContexMenu it's to add the ContexMenu in the Form or
do it in code, or you can add a class that inherits from treeview, and add
the contex menu in your class in the designer.


Thanks, Bela. I've tried creating a class that inherits from treeview, and
adding the context menu, but for some reason, when I click "Edit menu",
either nothing happens, or the "null reference" error appears. Does it work
okay in your setup? Maybe my VC.NET 2003 installation is broken.

A similar question: I've managed to add the context menu to the treeview
using the old copy/paste methodology, but is there any way to make the
shortcuts work? For example, if I add Ctrl-A to select all items, it works
fine when the menu is popped up, but doesn't work otherwise. Without
handling each keypress event, is there any way to have the menu
automatically handle the shortcuts while the control is focussed?

Thanks,
Aaron.
Nov 15 '05 #3
Sorry, it's don't work well, I put a user control put the menu in the user control edit the menu, and later change the class from user control to ListView and work well, (I think it a little weird), I guest that it's better do it in code, that this way, but it's almost a way, the problem it's because ListView don't have a design surface.



The answer to your second question it's that for default the shortcuts in the context menu don't get called until the menu it's visible, you can put the shortcuts in a Main Menu Item, and it will work.
--
Bela Istok
MVP C#
Caracas, Venezuela
"Aaron Queenan" <aq*********************@contingent.com.au> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
The only way to add a ContexMenu it's to add the ContexMenu in the Form or
do it in code, or you can add a class that inherits from treeview, and add
the contex menu in your class in the designer.


Thanks, Bela. I've tried creating a class that inherits from treeview, and
adding the context menu, but for some reason, when I click "Edit menu",
either nothing happens, or the "null reference" error appears. Does it work
okay in your setup? Maybe my VC.NET 2003 installation is broken.

A similar question: I've managed to add the context menu to the treeview
using the old copy/paste methodology, but is there any way to make the
shortcuts work? For example, if I add Ctrl-A to select all items, it works
fine when the menu is popped up, but doesn't work otherwise. Without
handling each keypress event, is there any way to have the menu
automatically handle the shortcuts while the control is focussed?

Thanks,
Aaron.
Nov 15 '05 #4
Thanks, Bela.

Unfortunately, I can't put the menu into the main menu, because it's a dialogue box for an Excel Plug-in.

On the plus side, I've tried assigning the ContextMenu property of the TreeView control, which solves the right-click problems, and some of the accelerators work. Ctrl-A works for selecting all, but Del doesn't work for some reason.

Aaron.
"Bela Istok" <be****@hotmail.com> wrote in message news:OF**************@TK2MSFTNGP10.phx.gbl...
Sorry, it's don't work well, I put a user control put the menu in the user control edit the menu, and later change the class from user control to ListView and work well, (I think it a little weird), I guest that it's better do it in code, that this way, but it's almost a way, the problem it's because ListView don't have a design surface.



The answer to your second question it's that for default the shortcuts in the context menu don't get called until the menu it's visible, you can put the shortcuts in a Main Menu Item, and it will work.
--
Bela Istok
MVP C#
Caracas, Venezuela
"Aaron Queenan" <aq*********************@contingent.com.au> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
The only way to add a ContexMenu it's to add the ContexMenu in the Form or
do it in code, or you can add a class that inherits from treeview, and add
the contex menu in your class in the designer.


Thanks, Bela. I've tried creating a class that inherits from treeview, and
adding the context menu, but for some reason, when I click "Edit menu",
either nothing happens, or the "null reference" error appears. Does it work
okay in your setup? Maybe my VC.NET 2003 installation is broken.

A similar question: I've managed to add the context menu to the treeview
using the old copy/paste methodology, but is there any way to make the
shortcuts work? For example, if I add Ctrl-A to select all items, it works
fine when the menu is popped up, but doesn't work otherwise. Without
handling each keypress event, is there any way to have the menu
automatically handle the shortcuts while the control is focussed?

Thanks,
Aaron.
Nov 15 '05 #5

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

Similar topics

6
by: Ed Sutton | last post by:
I am dynamically appending to a context menu when user right mouse clicks on a treeView. The first time I right-mouse click I see the appended menu. Subsequently, the menu items I append do not...
4
by: Phill | last post by:
Here's what I'm doing to make the right context mnue show up based on what node was cliked: private void tvwMenu_MouseUp(object sender, MouseEventArgs e) { //Select Node When Right Clicked &...
5
by: Dean L. Howen | last post by:
Dear friends, Could we determine when context menu should appear?
10
by: tmaster | last post by:
When I try to dynamically add a second sub menu item to this ContextMenu item, I get an error 'Specified argument was out of the range of valid values'. Private Sub mnuTopics_Show_Select(ByVal...
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...
2
by: Lucky | last post by:
hi guys, i'm working on the context menu for the controls. the problem i'm facing right now is like this : i want to use one context menu for more then one controls lets say i want to use one...
2
by: Ron M. Newman | last post by:
Hi, Just need a little advice. Id like to build *dynamic* context menus for tree nodes. I'm pretty versed in building context menus and attaching them to tree nodes. My question is, what...
2
by: Claire | last post by:
I've a treeview control containing a root node with several children on a windows form. I select a node with a left mouse button click. I then select one of the other nodes with right mouse click...
2
by: Bry | last post by:
I have a context menu which is shared between a TreeView and ListView control (both controls show the same information, similar to how Windows Explorer works, so it makes sense to use the same menu...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
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...
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...
0
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,...
1
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...
0
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...
0
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...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.