4

In my Winforms application I have a toolstrip which I set it's BackColor property to Black. All is good except the fact that every drop-down button on the toolbar draws its drop down arrow in black, thus makeing it invisible. My question is, how do I change the colour of this arrow? I looked for something useful in the toolstrip renderer but all I could found was ToolStripDropDownBackground. So, how do I make it white, for example? Thanks

Valentin Radu
  • 629
  • 1
  • 11
  • 26
  • You'd likely have to derive your own class for the button and change it, either through property or drawing it yourself. – DonBoitnott Jan 28 '14 at 19:09

1 Answers1

9

Create your own renderer:

public class MyRenderer : ToolStripRenderer {

  protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) {
    e.ArrowColor = Color.White;
    base.OnRenderArrow(e);
  }

}

To use it, set your ToolStrip control:

toolStrip1.Renderer = new MyRenderer();
LarsTech
  • 80,625
  • 14
  • 153
  • 225
  • I am stuck with System.Windows.forms.Toolbar() control. Is it possible to something like this with toolbar ? – Sakthivel Aug 07 '14 at 14:57
  • @shakthi I highly doubt that. There was a strong reason the Toolbar class got replaced with the ToolStrip class. – LarsTech Aug 07 '14 at 15:11
  • ok, i work on a large application. so will it be possible to replace the particular toolbar with toolstrip ? what would happen to the events if i do ? i found this link as well http://www.codeproject.com/Articles/12953/Upgrading-from-MainMenu-and-ToolBar-to-MenuStrip-a – Sakthivel Aug 07 '14 at 15:13
  • @shakthi It's not a drop-in replacement. You would have to rewire those click events to the new ones. I would try adding the ToolStrip to the form (so that you have both Toolbar and ToolStrip controls on the form at the same time) and then just work on recreating all of the buttons and their functions. When you are done, then delete the old ToolBar. Hopefully, you are using a Source Control (git, svn, etc) so that if it doesn't work, you can just revert back to the old code. If not, make a copy first. – LarsTech Aug 07 '14 at 15:17
  • I created a toolstrip with the above renderer. but my mouse hover doesnt change the border color and background color of dropdown button as it changes with default renderer. please help – Sakthivel Aug 08 '14 at 12:05
  • @shakthi I can't see your code. Try posting it in a new question. – LarsTech Aug 08 '14 at 12:07
  • @LarsTech here's my question http://stackoverflow.com/questions/25203599/converting-toolbar-to-toolstrip-control-and-mousehover-not-working – Sakthivel Aug 08 '14 at 12:31