Dynamically change icon appearance in menu strip

DanielB33

Active member
Joined
Mar 29, 2013
Messages
40
Programming Experience
1-3
I have a menu strip. In it, I would like to have the user select modes. These modes will rarely be changed. When they select a mode, I would like a dot or checkmark icon to appear in the menu strip by the item that is active. When the user switches modes, the icon will not appear and stay on the next menu strip item. How can I make the icon in the menu strip appear/disappear dynamically? I have been searching for hours and cannot find anything. It doesn't like the icon image has a visible property, only the whole menu strip item as far as I can tell. Thanks for the help.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,283
Location
Sydney, Australia
Programming Experience
10+
You shouldn't be using an icon at all. That is to indicate what the menu item does. Functionality to check and uncheck a menu item is already built into the menu item. It has Checked and CheckState properties, just like a CheckBox, and also a CheckOnClick property.
 

DanielB33

Active member
Joined
Mar 29, 2013
Messages
40
Programming Experience
1-3
You are the man. Thank a lot for that, I completely missed it.
Also, when I click the item for check on click, the toolstripmenu disappears, and I have clock tools-->strain guage ---> Selection -->M1 --> to select the next selection. The user will usually always change 2 items at a time. I would like them to not have to go through all of the options to change the item again. Is there a way to have the menu strip not close when clicking certain items?
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,283
Location
Sydney, Australia
Programming Experience
10+
Is there a way to have the menu strip not close when clicking certain items?
While I haven't tested the theory, I think that you will need to define your own class that inherits ToolStripMenuItem and override its DismissWhenClicked property to return False, then use that class instead of the standard ToolStripMenuItem for those menu items.
 
Top Bottom