So I have a MenuStrip
with a couple of ToolStripMenuItem
s. Two of my ToolStripMenuItem
components are having a background image (battery icon and shutdown icon).
Now I want to disable the default MenuStrip
mouse hover effect (that blueish background) for the ToolStripMenuItem
elements which I have set a background. To achieve this I have override the OnRenderMenuItemBackground
event implementation, like this:
internal class NoHighlightRenderer : ToolStripProfessionalRenderer
{
protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
{
if (e.Item.OwnerItem != null)
{
base.OnRenderMenuItemBackground(e);
}
}
}
And use this custom renderer for my MenuStrip
like this:
myMenuStrip.Renderer = new NoHighlightRenderer();
This works fine for the elements that don't have a background image set. For the ones with the background set, the background image will not show.
I want the background image to be visible, how to do this?