c# - Change the border color of Winforms menu dropdown list -


is possible change border color of toolstrip menu dropdown list.

in sample below dropdown menu have 1 color (blue) without white border being displated, keeping main menu ('my menu') item white.

any ideas?

enter image description here

is possible change border color of toolstrip menu dropdown list.

yes. class inherits professionalcolortable works expected:

class menucolortable : professionalcolortable {     public menucolortable()     {         // see notes         base.usesystemcolors = false;     }     public override system.drawing.color menuborder     {         get{return color.fuchsia;}     }     public override system.drawing.color menuitemborder     {         get{return color.darkviolet;}     }     public override color menuitemselected     {         { return color.cornsilk;}     }     public override color menuitemselectedgradientbegin     {         get{return color.lawngreen;}     }     public override color menuitemselectedgradientend     {         { return color.mediumseagreen; }     }     public override color menustripgradientbegin     {         { return color.aliceblue; }     }     public override color menustripgradientend     {         { return color.dodgerblue; }     } } 

in form load:

menustrip1.renderer = new toolstripprofessionalrenderer(new menucolortable()); 

if visual styles not turned on, not color table items used , systemcolors used instead. enable visual styles in main():

// must done before ui elements used application.enablevisualstyles(); 

you may want disable system colors shown in ctor. default should false whether visual styles enabled or not, maybe else has changed it?

base.usesystemcolors = false; 

both enablevisualstyles() , usesystemcolors = false; have in place all rendering elements in color table implemented, otherwise used. (though, menuborder seem work no matter what.) otherwise, results expected:

enter image description here

the menu gradient goes aliceblue dodgerblue; item mouse on uses top bottom gradient of lawngreen mediumseagreen (mouse not shown).

enter image description here

when open, menu border fuschia (mmmm, soothing!)

enter image description here

with mouse on 1 of items (mouse not shown), item uses menuitemselected color consilk.

if having trouble getting overrides work, check using right ones (or mean name implies, misleading @ first).

you might check using menustrip menu, net have (older) menu class though have go searching find it. might change or disable theme see if might causing adverse effects.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -