BUG: Select Event in MenuItem Class Does Not Fire After Adding a Submenu at Runtime (328589)
The information in this article applies to:
- Microsoft .NET Framework 1.0 SP2
This article was previously published under Q328589 SYMPTOMS
If you add a submenu at runtime, the Select event in the MenuItem class does not fire the first time that you move the pointer over the command.
CAUSE
When a submenu is added, handles for the items that were already in the MenuItem collection are discarded.
RESOLUTION
To resolve the issue, get a reference to the handle of MenuItem. This will forcibly re-create the handle for the MenuItem. The following sample code demonstrates how to do this.
Visual Basic .NET
Dim NewMenu As MenuItem
NewMenu = mnuViews.MenuItems.Add("TestMenu")<BR/>
'Immediately after adding the menu item, add the following statement:
Dim handle As IntPtr = mnuViews.Handle
C#
MenuItem nMenu = new MenuItem("TestMenu");
mnuViews.MenuItems.Add(nMenu);
//Immediately after adding the menu item, add the following statement:
IntPtr handle = mnuViews.Handle;
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Major | Last Reviewed: | 2/12/2003 |
---|
Keywords: | kbbug kbNetFrame100preSP3fix KB328589 |
---|
|