473,387 Members | 1,899 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,387 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 1250

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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.