473,322 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,322 software developers and data experts.

Problem with dynamically populated Contextmenu

Joe
I have a MenuItem which is was added to the context menu at design time. The
context menu is for a button on a toolbar. At runtime I add and remove
sub-menuitems to and from this menu item. The problem is the dynamically
added items don't always appear.

If I add say 3 menu items and click to see the menu, the sub menu appears
and shows 3 items. This is fine. Now, if I add another item and click to see
the submenu, nothing displays. The arrow is there and there is a count of 4.
I also checked to make sure they're all set to visible and they are.

Any suggestions?

// Add menu item
miShow.MenuItems.Add(itemText, new EventHandler(mi_Click) );

// Remove menu item
miShow.MenuItems.Remove(mi);

//Also tried clearing and re-adding all of them but still no luck
miShow.MenuItems.Clear();
foreach (string s in mystringarray)
miShow.MenuItems.Add(s, new EventHandler(mi_Click) );

Nov 17 '05 #1
1 2214
Joe wrote:
I have a MenuItem which is was added to the context menu at design time. The
context menu is for a button on a toolbar. At runtime I add and remove
sub-menuitems to and from this menu item. The problem is the dynamically
added items don't always appear.

If I add say 3 menu items and click to see the menu, the sub menu appears
and shows 3 items. This is fine. Now, if I add another item and click to see
the submenu, nothing displays. The arrow is there and there is a count of 4.
I also checked to make sure they're all set to visible and they are.

Any suggestions?

// Add menu item
miShow.MenuItems.Add(itemText, new EventHandler(mi_Click) );

// Remove menu item
miShow.MenuItems.Remove(mi);

//Also tried clearing and re-adding all of them but still no luck
miShow.MenuItems.Clear();
foreach (string s in mystringarray)
miShow.MenuItems.Add(s, new EventHandler(mi_Click) );

Im just guessing here but are you retaining a reference to your added
menu item (mi)?

JB
Nov 17 '05 #2

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

Similar topics

4
by: Thomas | last post by:
Hi there, I have an iframe which is editable (designMode = "on") and want to resize it dynamically as the content grows (e.g. more lines of text is in there) and there the struggle starts. I...
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...
1
by: Brian Martel | last post by:
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...
4
by: Claire | last post by:
Sorry Ive added this twice (sortof) but if I'd added an addendum to the first one then this would probably have been ignored. This problem affects a ContextMenu attached to a NotifyIcon object. I...
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...
7
by: Steve_Black | last post by:
Hello, I'm toying with the idea of loading a MenuStrip (VB.Net 2005) dynamically based on who is logged into my system. Every user has different security settings and I want to customize the...
3
by: rn5a | last post by:
A SqlDataReader is populated with the records from a SQL Server 2005 DB table. The records retrieved depends upon 2 conditions (the conditions depend on what a user selects in an ASPX page). If...
1
by: Sharon | last post by:
Hello All, I have a gridview control in webform which is dynamically populated on page startup with a query. I was trying to change the header text for the columns and also set wrap to false. i...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.