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 white border currently being displated, but keeping the main menu ('My Menu') item white.
Any ideas?
You can give the items negative margins to cover up the border.
Is it possible to change the border color of a toolstrip menu dropdown list.
Yes. A class which inherits from
ProfessionalColorTable
works as expected:In form load:
If visual styles are not turned on, not all the color table items will be used and some
SystemColors
will be used instead. You enable visual styles inMain()
:You may want to also disable system colors as shown in the ctor. The default should be false whether visual styles are enabled or not, but maybe something else has changed it?
Both
EnableVisualStyles()
andUseSystemColors = false;
have to be in place for all the rendering elements in your color table to be implemented, otherwise only some are used. (Though,MenuBorder
does seem to work no matter what.) Otherwise, results are as expected:The menu gradient goes from AliceBlue to DodgerBlue; an item with the mouse over it uses a top to bottom gradient of LawnGreen to MediumSeaGreen (mouse not shown).
When open, the menu border is Fuschia (mmmm, soothing!)
With the mouse over one of the items (mouse not shown), the item uses the
MenuItemSelected
color which was Consilk.If you are having trouble getting your overrides to work, check that you are using the right ones (or that they mean what the name implies, some are misleading at first).
You might also check that you are using a
MenuStrip
for the menu, Net does have another (older) menu class though you have to go searching to find it. You might also change or disable any Theme to see if that might be causing adverse effects.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:
Solution 1
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
Form Load Code
Screenshot
Here is normal screenshot
And here is a 2x magnified screenshot:
Solution 2
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).
I can't make the demo application right now, but screenshots in this article http://www.vbforums.com/showthread.php?596563-100-Customizable-MenuStrip-ToolStrip-StatusStrip-including-common-presets proves us that changing of border color is possible.
That guy have developed some library but it is based on standard ToolStrip implementation.
I hope this link will be helpful.