I add a MenuStrip
in my app and is add on ManagerRenderMode
at Render Mode
. The problem is with the appearance, look offal. Look at those two photos, I want to change that white border of submenus in transparent, that blue rectangule that look offal on gray for the menu and for the submenu in dark gray (and his border that is a dark blue) and the border white of menu when is selected. How I can do this ?
BackColor
is: 36; 36; 36
and ForeColor
is LightGray
.
I managed to change the blue rectangle, the white rectangle when the option is selected, the blue rectangle when I select an option of submenus, but I don't know how to change the white border
, please help..
Here is the code so far...
Color culoare = Color.FromArgb(20, 20, 20);
Color culoare1 = Color.FromArgb(36, 36, 36);
public override Color MenuItemSelected
{
get { return culoare; }
}
public override Color MenuItemBorder
{
get { return culoare; }
}
public override Color MenuItemSelectedGradientBegin
{
get { return culoare; }
}
public override Color MenuItemSelectedGradientEnd
{
get { return culoare; }
}
public override Color MenuItemPressedGradientBegin
{
get { return culoare; }
}
public override Color MenuItemPressedGradientEnd
{
get { return culoare; }
}
public override Color MenuBorder
{
get { return culoare; }
}
The MenuStrip control supports the multiple-document interface (MDI) and menu merging, tool tips, and overflow. You can enhance the usability and readability of your menus by adding access keys, shortcut keys, check marks, images, and separator bars.
The MenuStrip control represents the container for the menu structure. The MenuStrip control works as the top-level container for the menu structure. The ToolStripMenuItem class and the ToolStripDropDownMenu class provide the functionalities to create menu items, sub menus and drop-down menus.
We can add items to a MenuStrip at design-time from Properties Window by clicking on Items Collection as you can see in Figure 4. When you click on the Collections, the String Collection Editor window will pop up where you can type strings. Each line added to this collection will become a MenuStrip item.
MenuStrip is the top-level container that supersedes MainMenu. It also provides key handling and multiple document interface (MDI) features.
You can do this by creating your own ColorTable, and overriding the properties you wish to change the colour of:
public class TestColorTable : ProfessionalColorTable
{
public override Color MenuItemSelected
{
get { return Color.Red; }
}
public override Color MenuBorder //added for changing the menu border
{
get { return Color.Green; }
}
}
You would use it like this:
private void Form1_Load(object sender, EventArgs e)
{
menuStrip1.Renderer = new ToolStripProfessionalRenderer(new TestColorTable());
}
Your approach is incorrect. You do not style menus and toolstrips using forecolor/backcolor.
Take a look at ToolStripProfessionalRenderer
Example on how to use this
public class MyToolStripRenderer : ToolStripProfessionalRenderer
{
/* override styling/drawing here */
}
MenuStrip strip = new MenuStrip();
strip.Renderer = new MyToolStripRenderer();
//this will set RenderMode to "Custom"
consider using this example on CodeProject as some research.
Better still, VBForums have loads of them, already implemented (in the usual Luna, Office, Windows, Visual Studio styles!)
http://www.vbforums.com/showthread.php?596563-100-Customizable-MenuStrip-ToolStrip-StatusStrip-including-common-presets
If you simply want to chaneg the colors...use Pondidum's answer! It involves less work!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With