i would like to uncheck all menu items of a main ToolStripMenuItem (called MyMainMenu) in a MenuStrip when i click on another menu entry. The main menu contains some menu items and a separator. I tried the following code:
Private Sub CheckCheckedStatusMenu(ByVal MnuItem As ToolStripMenuItem)
MnuItem.Checked = True
For Each Mnu As ToolStripMenuItem In Me.MyMainMenu.DropDownItems
If Not Mnu Is MnuItem Then
Mnu.Checked = False
End If
Next
End Sub
I call that code from every menu item (except the separator). When i click on a menu item, the program crash saying that he can't make the cast from ToolStripSeparator to ToolStripMenuItem. The same code can be found on the Microsoft .NET documentation site for similar purposes, but it does not specify what can be done in case the same menu item contains different kind of items (separators, textboxes...).
Do you know how can i fix this problem?
Thanks,
Bye