How do you make a menu item checkable? I have dragged the Main Menu onto my form and created an options menu, within that i want some of the items to be checkable. I tried dragging a checkbox onto the menu item, but that didnt work
Printable View
How do you make a menu item checkable? I have dragged the Main Menu onto my form and created an options menu, within that i want some of the items to be checkable. I tried dragging a checkbox onto the menu item, but that didnt work
Open the property window after selecting the menuitem in the design mode and set the Checked property to True.
If you're using the MainMenu I assume that you're using .NET 1.x (please specify in future). Setting the Checked property of the menu item in the designer will make it appear checked but it doesn't help you at run time. You should double click the menu item to create a Click event handler and then add code like this:This will toggle the check mark each time you click the menu item. By casting the sender as I have done you could use the same event handler for multiple menu items. If you're just using it for one you could hard code the name of the menu item rather than using a cast.VB Code:
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click Dim item As MenuItem = DirectCast(sender, MenuItem) item.Checked = Not item.Checked End Sub
Using the Menu's properties, you could also add a dot (like a radiobutton) - RadioCheck to your menu items, if desired.... :rolleyes:
RadioCheck doesn't actually affect the checking of the item. It just displays a dot instead of a tick when the Checked property is True.Quote:
Originally Posted by HanneSThEGreaT
I never said it effects the checking of the item ;)Quote:
Originally Posted by jmcilhinney
I just mentioned that it is also possible to add a dot in front of a menu item.