I'm making a windows form application that has a timeline not to different from one found in video editing software.
The controls on this time line are a custom class that inherits Button.
I want the user to be able to click the button once to select it (highlighted) and once again to unselect it. This is so the user can select several timeline it开发者_开发百科ems at once.
Is there any way to do this in C#?
Well actually you would be better off with CheckBox control and you can make it look just like regular button:
Note that you can assign each button with a different 'Group' property so that each one of them can be separately check or unchecked.
May be more suitable solution to you is create a derived control from RadioButton or CheckBox, that stores Pressed/Checked state information.
If you can not, for 1000 of reasons that could be, you can add state management to your custom Button class.
Hope this helps.
Regards.
精彩评论