JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Adding Checkmarks to Menu Items

You can also add a checkmark to a menu item, which you usually use to indicate to the user that a specific option has been selected—you can see an example in front of the Spell Checking menu item in Figure 9.1 in the Menus example on the CD-ROM. To add a checkmark to a menu item at design time, just click to the left of its caption. There's a checkbox there, and if you click it, you'll toggle a checkmark on and off; you can see the checkmark in Figure 9.13.

You can use the Checked property of a MenuItem object to toggle the checkmark; True means the checkmark is displayed, False means it's hidden. In the Menus example on the CD-ROM, the checkmark in front of the Spell Checking item toggles on and off when you select that item, because I flip the logical sense of the Checked property with the Not operator that we saw in Chapter 2:

Private Sub MenuItem7_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MenuItem7.Click
    MenuItem7.Checked = Not MenuItem7.Checked
End Sub

Related solution:

Found on page:

Using Visual Basic Operators

88

Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor