+ Reply to Thread
Results 1 to 3 of 3

Thread: Seperators in menus

  1. #1
    kblair's Avatar
    kblair is offline VB.NET Forum Newbie kblair is on a distinguished programming path ahead
    .NET Framework
    .NET 3.5
    Join Date
    Feb 2010
    Age
    51
    Posts
    3
    Reputation
    0

    Default Seperators in menus

    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.

    Code:
     
        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

  2. #2
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute JohnH has a reputation beyond repute
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Age
    37
    Posts
    10,843
    Reputation
    1443

    Default

    Check type:
    Code:
    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:
    Code:
    For Each item As ToolStripMenuItem In TestToolStripMenuItem.DropDownItems.OfType(Of ToolStripMenuItem)()
        item.Checked = True
    Next

  3. #3
    kblair's Avatar
    kblair is offline VB.NET Forum Newbie kblair is on a distinguished programming path ahead
    .NET Framework
    .NET 3.5
    Join Date
    Feb 2010
    Age
    51
    Posts
    3
    Reputation
    0

    Default

    Duh, thanks John for pointing out the obvious. Sometimes it just takes another set of eyes.

    Kent

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts