473,404 Members | 2,114 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,404 software developers and data experts.

ContextMenu problem

I am trying to create a dynamic flyout submenu off of a contextmenu.
I can right click and get the base contextmenu ok.
On the Popup event I add MenuItem's to the collection of one of the items so
it has a flyout submenu when selected.
If I try and add more than 1 item to the submenu it only shows up the first
time.
This same code works fine if it is part of a MainMenu but not with a
ContextMenu.

Has anyone seen this before? Have you found a work around?

Here is a sample of the code that I use in the Popup event for the
contextmenu.
(mnuExisting is one of the menu items in the context menu)

MenuItem[] aMi = new MenuItem[2];
aMi[0] = new MenuItem("SubMenu Item 1");
aMi[1] = new MenuItem("SubMenu Item 2");
mnuExisting.MenuItems.Clear();
mnuExisting.MenuItems.AddRange(aMi);

This will work the first time the contextmenu it shown but the submenu
doesn't show after that.
If I change this to add an array of 1 it works every time.

Thanks for any help.
Nov 15 '05 #1
1 2000
I think its because you use Popup event.
Try to move menu creation code into MouseDown - for right-click. And maybe
in related keypress handler if you use it.
Also, you might try to recreate full context menu, not only submenu items.

I create complete context menu on right-click. It never failed. But it was
recreated on every right-click.

HTH
Alex

"Brian Martel" <brian.martel_NO_SPAM_@_PLEASE_thermogalactic.co m> wrote in
message news:OO**************@TK2MSFTNGP09.phx.gbl...
I am trying to create a dynamic flyout submenu off of a contextmenu.
I can right click and get the base contextmenu ok.
On the Popup event I add MenuItem's to the collection of one of the items so it has a flyout submenu when selected.
If I try and add more than 1 item to the submenu it only shows up the first time.
This same code works fine if it is part of a MainMenu but not with a
ContextMenu.

Has anyone seen this before? Have you found a work around?

Here is a sample of the code that I use in the Popup event for the
contextmenu.
(mnuExisting is one of the menu items in the context menu)

MenuItem[] aMi = new MenuItem[2];
aMi[0] = new MenuItem("SubMenu Item 1");
aMi[1] = new MenuItem("SubMenu Item 2");
mnuExisting.MenuItems.Clear();
mnuExisting.MenuItems.AddRange(aMi);

This will work the first time the contextmenu it shown but the submenu
doesn't show after that.
If I change this to add an array of 1 it works every time.

Thanks for any help.

Nov 15 '05 #2

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

Similar topics

0
by: MD | last post by:
I have a ContextMenu that is assigned to 3 RichTextBox's (i.e., if you right-click on any of the 3 RichTextBox's, you get the same ContextMenu). My ContextMenu has 2 items, each of which have their...
0
by: Stefan | last post by:
I've a weird problem. I use a contextmenu to do some staff after clicking the contextmenuitem. all works fine on my pc (win2k). If the application runs on the customers pc (NT4) the contextmenu...
0
by: Valerie Hough | last post by:
I have two different cases: 0) I right click the mouse button on a list box on my form, then in the Popup handler for the list box I use SendKeys to send three characters at once (the mnemonics...
0
by: Daniel K. | last post by:
I've got a form with a usercontrol and a contextmenu for it. I put everything together in the VS form designer. the codesnipped below is from that dialog. The problem: Before i added the...
2
by: Zieben | last post by:
Hello! I have such problem! I have my UserControl. I override property ContextMenu for this Control as ..... new ContextMenu ContextMenu{ set {_contextMenu = value;}
0
by: cemino | last post by:
Hi, I got a problem with ContextMenu. I'm using a hot-key (like Ctrl-B) to show contextMenu in my program. Things is like below: contextMenu.Show(Form1, New...
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...
11
by: Graham Charles | last post by:
I'm writing a control inheriting from ComboBox, and I'd like to add an entry to the ContextMenu for that combo box. I have no problem if I create an entirely new ContextMenu from scratch, but I'd...
3
by: asharda | last post by:
Hi, I am trying to create a context menu in my application. The context menu takes menu otems from an XML file. In XAML the code is <Grid.ContextMenu> <ContextMenu Name="cm" StaysOpen="true"...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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,...

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.