I am able to have checked menu items show the variables that I need to show, but they don't uncheck themselves unless I go back and click them. I want to have only one checkmark on a country at a time...is there any way? I've tried if...elseif , but that doesn't work....example below (If I only want Mexico checked and NOT United States, but both are checked still).

If MexicoToolStripMenuItem.CheckState = CheckState.Checked Then
   UnitedStatesToolStripMenuItem.CheckState=CheckState.Unchecked...
End IF

Recommended Answers

All 2 Replies

In the properties window make sure CheckedOnClick equals true for each of the menu items.

Add to your menu item events:

mnuUnitedStates_Click
mnuMexico.Checked = Not mnuUnitedStates.Checked
End Sub

mnuMexico_Click
mnuUnitedStates.Checked = Not mnuMexico.Checked
End Sub

Make sure that all your Country DropDownItems CheckOnClick is True

' M A I N   M E N U   S T R I P
    ' File (mnuFile)
    ' ' ' Exit (mnuExit)
    ' Country (mnuCountries)
    ' ' ' South Africa
    ' ' ' Afghanistan
    ' ' ' New Zealand
    ' ' ' United Kingdom
    ' ' ' United States

    ''' <summary>
    ''' This function will uncheck all the mnuCountries DropDownItems, except for the sender
    ''' </summary>
    ''' <param name="sender">This will be a ToolStripMenuItem</param>
    Sub ChangeMenuCheckState(ByVal sender As Object)
        Dim mnuItem As ToolStripMenuItem = sender
        For Each item As ToolStripMenuItem In mnuCountries.DropDownItems
            If item.Name <> mnuItem.Name Then
                item.CheckState = CheckState.Unchecked
            End If
        Next
    End Sub
    Private Sub mnuSouthAfrica_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuSouthAfrica.Click
        ChangeMenuCheckState(sender)
    End Sub
    Private Sub mnuAfghanistan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAfghanistan.Click
        ChangeMenuCheckState(sender)
    End Sub
    Private Sub mnuNewZealand_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuNewZealand.Click
        ChangeMenuCheckState(sender)
    End Sub
    Private Sub mnuUK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuUK.Click
        ChangeMenuCheckState(sender)
    End Sub
    Private Sub mnuUS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuUS.Click
        ChangeMenuCheckState(sender)
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.