Is it possible to change the border color of a toolstrip menu dropdown list.
In my sample below I would like the dropdown menu to have 1 color (blue) without the whi
To Change the border color it is enough to follow Plutonix solution that is described in accepted answer. But to remove that white border between the item and menu border, you should follow one of these solution:
You can do it by implementing your custom color table that inherits ProfessionalColorTable and overriding correct properties. To do so, follow these steps:
Steps
CustomColorTable Code
public class CustomColorTable:ProfessionalColorTable
{
public override Color ImageMarginGradientBegin
{
get
{
return Color.MidnightBlue;
}
}
public override Color ImageMarginGradientMiddle
{
get
{
return Color.MidnightBlue;
}
}
public override Color ImageMarginGradientEnd
{
get
{
return Color.MidnightBlue;
}
}
public override Color ToolStripDropDownBackground
{
get
{
return Color.MidnightBlue;
}
}
}
Form Load Code
private void Form_Load(object sender, EventArgs e)
{
ToolStripManager.Renderer = new ToolStripProfessionalRenderer(new CustomColorTable());
}
Screenshot
Here is normal screenshot
And here is a 2x magnified screenshot:
There is also an alternative solution that is applicable if you don't want to use images in your menu items. In this case, find the DropDown property of your dropdownbutton and cast it to ToolStripDropDownMenu, then set ShowImageMargin property of it to false and BackColor of it to the color you want (blue).
private void Form_Load(object sender, EventArgs e)
{
//The item with text "My Menu" in your sample
var dropDownMenu = (ToolStripDropDownMenu)this.myMenuToolStripDropDownButton1.DropDown;
dropDownMenu.ShowImageMargin = false;
dropDownMenu.BackColor = Color.Navy;
}