Reputation: 11
I have created this form and a custom function that paints the background of the control with a darkened piece of the forms background.
On hover the control area is highlighted, Is there an accessor to this color? Like menustrip.Highlight Color?
I have been unable to find the accessor for the sub menus as well. I have looked on msdn and have found articles on the ability to change the entire theme, color only, no information on how to set a background image. I have searched SO and found similar topics but none that answer my question or close enough to extrapolate the correct answer. Any assistance would be greatly appriciated. Written in C#. Also, is the submenu a added to the list of controls when it exists?
Upvotes: 1
Views: 3166
Reputation: 69
Private Sub BackImageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackImageToolStripMenuItem.Click
Me.MenuStrip1.BackgroundImage=Form1.My.Resources.Resources.nature 'where nature is image name
BackImageToolStripMenuItem.Checked = True
End Sub
Upvotes: 1
Reputation: 236318
You should use ToolStripRenderer to customize menu look. Assign renderer to menu and call invalidate:
menuStrip.Renderer = new ToolStripProfessionalRenderer(new DarkColorTable());
menuStrip.Invalidate();
As you can see, renderer requires color table. You should create custom one and override all colors you want to customize:
public class DarkColorTable : ProfessionalColorTable
{
public override Color MenuStripGradientBegin
{
get { return Color.FromArgb(128, Color.Black); }
}
public override Color MenuStripGradientEnd
{
get { return Color.FromArgb(128, Color.Black); }
}
public override Color ButtonSelectedHighlight
{
get { return Color.FromArgb(64, Color.Black); }
}
// etc
}
Upvotes: 2