Link to home
Start Free TrialLog in
Avatar of lep1
lep1

asked on

Programatically Uncheck ToolStripMenuItems

I have several different type of picture formats that the user can select using a check in each menuitem.   An Addhandler is used in Form1.Load to trigger the MyMenuClick subroutine.   Thus far, however, the code hangs in the CheckMenuItem function on the "m.checked = checked" line.   For some reason, it is challenging to uncheck and check toolstripmenuitems -- so am I leaving out a CType (cast) or do I need a sender.sourcecontrol?


Private Function checkMenuItem(ByRef m As ToolStripMenuItem, ByVal checked As Boolean)
If m IsNot Nothing Then
     m.Checked = checked   'hang occurs on this line
     Return True
Else
     Return False
End If
End Function

Private Sub MyMenuClick(sender As Object, e As EventArgs)
        checkMenuItem(WmfToolStripMenuItem, False)
        checkMenuItem(JpgToolStripMenuItem, False)
        checkMenuItem(GifToolStripMenuItem, False)
        checkMenuItem(TifToolStripMenuItem, False)
        checkMenuItem(BmpToolStripMenuItem, False)
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial