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

MDI MenuItem Popup event - can't use MenuItems.Add

I'm trying to add menu items dynamically in the Popup event of a MenuItem in
an MDI child form. Actually, I'm using the Genghis MRU class, but have also
dumbed it down to a simple test case in a standard WinForms app.

When trying to call mnuItemFoo.MenuItems.Add( "some text" ) in the Popup
handler, I get a null reference exception.
System.NullReferenceException
Object reference not sent to an instance of an object.
It's weird - the call to MenuItems.Add is successfull. Only when I leave
the Popup handler, do I get the exception, thrown from deep in the callstack
at MenuItem.UpdateMenuItemIfDirty( ) ???

My form is an MDI child, and the menu I'm trying to add to is a merged menu
(i.e. "File" menu) with the MDI container.

Anybody else run into this? Is there a work around?

The only thing I can get to work is to dynamically add the menu items
somewhere else, other than the Popup event. (e.g. when a "document" is
opened, add the MenuItem right then, not later when the user clicks the
menu)


Jul 21 '05 #1
0 1246

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

Similar topics

4
by: Jesper | last post by:
Hi, When creating a popup menu I find it rather difficult to provide the eventhandler for the MenuItem with enough information. My actual problem is that I create a popup menu with a list of...
0
by: ZH | last post by:
Hi There, I have an application that runs from the systray. When the user right clicks on the icon it shows the user a list of of menu items. That works without a problem. The problem is...
1
by: snesbit | last post by:
I have a static ContextMenu already built and it works. I am trying to add a submenu (right arrow with a new menuitem list) dynamically when the popup is created. The new set of menuitems...
0
by: **Developer** | last post by:
MenuItemPasteSpecial.MenuItems.Clear() jnk = MenuItemPasteSpecial.MenuItems.Add(New MenuItem("Locale", AddressOf HandlesMenuItemPasteSpecial_Click)) 'MenuItemPasteSpecial.MenuItems(jnk).MergeType...
0
by: **Developer** | last post by:
Sorry this is the second post but I had left the most important clue out of the first one. If I only have one MenuItem.Add it works OK! MenuItemPasteSpecial.MenuItems.Clear() jnk =...
0
by: **Developer** | last post by:
Private Sub ContextMenuEdit_Popup(ByVal sender As Object, ByVal e As EventArgs) Handles ContextMenuEditor.Popup MenuItemPasteSpecial.MenuItems.Add(0, New MenuItem("Locale", AddressOf...
0
by: Dan H | last post by:
I'm trying to add menu items dynamically in the Popup event of a MenuItem in an MDI child form. Actually, I'm using the Genghis MRU class, but have also dumbed it down to a simple test case in a...
0
by: **Developer** | last post by:
A MDI form has a MenuItem "File" that contains other MenuItems. A MdiChild form also contains a "File" MenuItem containing other MenuItems. They are both mergetype MergeItems and mergeindex=0...
2
by: polocar | last post by:
Hi, I'm writing a program using Visual C# 2005 Professional Edition, and I was trying to assign multiple MainMenu objects (one by one, of course) to the same Form (let's suppose 2 MainMenu...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.