Seperators in menus

kblair

Member
Joined
Feb 11, 2010
Messages
8
Programming Experience
1-3
I have routine that I use to turn off all of the check marks on various menus. The code works fine as long as there are no menu seperators.

VB.NET:
    Private Sub ClearMenuChk()

        Dim mnuItm As ToolStripMenuItem

        For Each mnuItm In mnuZoom.DropDownItems
            mnuItm.Checked = False
        Next

        For Each mnuItm In mnuAnnotation.DropDownItems
            mnuItm.Checked = False
        Next

        For Each mnuItm In mnuAnnotRubStamps.DropDownItems
            mnuItm.Checked = False
        Next


    End Sub

How do ignore the seperators that are of the wrong type and contiue unchecking the rest of the items? I have tried on error resume next but it still drops out of the for each loop so that only the items above the seperator are un-checked.

Thanks for your help,

Kent
 
Check type:
VB.NET:
For Each item As ToolStripItem In mnuZoom.DropDownItems
    If TypeOf item Is ToolStripMenuItem Then
        CType(item, ToolStripMenuItem).Checked = False
    End If
Next
or filter out items:
VB.NET:
For Each item As ToolStripMenuItem In TestToolStripMenuItem.DropDownItems.OfType(Of ToolStripMenuItem)()
    item.Checked = True
Next
 
Back
Top