|
-
May 24th, 2006, 04:07 AM
#1
Thread Starter
Lively Member
[RESOLVED] Adding a check box to a menu
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
-
May 24th, 2006, 04:13 AM
#2
Re: Adding a check box to a menu
Open the property window after selecting the menuitem in the design mode and set the Checked property to True.
Use [code] source code here[/code] tags when you post source code.
My Articles
-
May 24th, 2006, 04:26 AM
#3
Re: [RESOLVED] Adding a check box to a menu
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:
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
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.
-
May 24th, 2006, 04:59 AM
#4
Re: [RESOLVED] Adding a check box to a menu
Using the Menu's properties, you could also add a dot (like a radiobutton) - RadioCheck to your menu items, if desired....
VB.NET MVP 2008 - Present
-
May 24th, 2006, 05:46 AM
#5
Re: [RESOLVED] Adding a check box to a menu
 Originally Posted by HanneSThEGreaT
Using the Menu's properties, you could also add a dot (like a radiobutton) - RadioCheck to your menu items, if desired.... 
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.
-
May 24th, 2006, 06:05 AM
#6
Re: [RESOLVED] Adding a check box to a menu
 Originally Posted by jmcilhinney
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.
I never said it effects the checking of the item
I just mentioned that it is also possible to add a dot in front of a menu item.
VB.NET MVP 2008 - Present
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|