ContextMenuStrip bug: ToolStripMenuItem fires on main form's ContextMenuStrip, while a modal dialog is still showing - resulting in "Form that is already visible cannot be displayed as a modal...
When a "modal dialog" is active, the main form still accepts and fires ToolStripItem events residing on a ContextMenuStrip.
This is a very frustrating and unacceptable behaviour.
When I thought my form's designer code had become corrupt, I was led to rebuild my application's main form from scratch, but the problem re-emerged! :mad:
I was surprised to find no discussing about this problem at any programming forum. Could I possible be the only person to come across this so-obvious bug? :confused:
I would really appreciate a solution or workaround. :rose:
This thing has had me tiring my hair out! :sigh:
This is regarding Visual Studio 2008 SP1 .NET 3.5.
Start a project and add an About Box to the project.
Add a ContextMenuStrip to the main form.
Add a MenuItem (with "F1" for the ShortcutKeys property, and "About" for the Text property) to the ContextMenuStrip.
Add a ToolStrip to the main form.
Add a DropDownButton to the ToolStrip.
Update DropDown property of DropDownButton to be the ContextMenuStrip.
Apply the following code to the main form:-
public partial class MainFrm : Form
AboutDlg aboutDlg = new AboutDlg();
private void toolStripMenuItem1_Click(object sender, EventArgs e)
private void toolStripMenuItem2_Click(object sender, EventArgs e)
Now, run the program and press F1 to show the dialog, and press F1 while the "modal dialog" is still active ...and boom - InvalidOperationException