I got a toolstripbutton, and when I click it, I want to make it stay “pressed” or “selected”. Like a switch. And when I click another, make the pressed one “unpressed” again. Any ideas?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think you want to use the
CheckOnClickproperty. Set it totrue, and the button should behave as you describe. In order to get (or set) the current state, use theCheckedproperty.Here is a full working sample:
firstButtonandsecondButtonareToolStripButtons, both haveCheckOnClickset totrue, and theirClickedevents hooked up toToolStripButton_Click. This works also if there are more than two buttons in the group of buttons in which only one should be checked, just add any needed additional buttons to themutuallyExclusiveButtonssequence.