Search code examples
c#winformstoolstrip

Make a ToolStrip Button staying highlighted when clicked in C#


I have a simple ToolStrip with buttons in it which contain images and text. When I go over that button it changes appearance (same when it gets clicked). How can I customize this so that it stays highlighted when clicked? I have to do this over a tabControl so that it stays highlighted when the tab is entered and gets back to its normal appearance when leaving the tab. Which methods do I have to override?

Thank you!


Solution

  • just set ToolStripButton.CheckOnClick property to true from design time. So it will stay highlited when clicked.

    About the other requirement set ToolStripButton.Checked to true on entring the tab control, and set it to false on leaving the tab control.

    For entering and leaving you may use Control.Leave & Control.Enter events of tabpage/tabcontrol.

    Let me know incase of any issues