I use a ToolStrip
in a C# winform application.
As I move the mouse over a button it gets highlighted (transparent blue color), I would like to change this color
I tried to use a custom renderer class
toolStrip1.Renderer = new MyRenderer();
....
class MyRenderer : ToolStripProfessionalRenderer
{
}
However, I don't know which method I should override to change that color.
Actually, there is no built-in way (or at least I am not aware of it).
class MyRenderer : ToolStripProfessionalRenderer
{
protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
{
if (!e.Item.Selected)
{
base.OnRenderButtonBackground(e);
}
else
{
Rectangle rectangle = new Rectangle(0, 0, e.Item.Size.Width - 1, e.Item.Size.Height - 1);
e.Graphics.FillRectangle(Brushes.Green, rectangle);
e.Graphics.DrawRectangle(Pens.Olive, rectangle);
}
}
}