Share via


Going from Blue to Tan

Brett asks:

During the PDC we chatted about how to make the toolbar have the same look and feel that the toolbar in Visual Studio has (namely the tan gradients as opposed to the blue ones) and you mentioned you would be posting on that soon ... so, I was wondering ... if you had any idea when that post would be online!?

Thanks for reminding me! 

Turning off the Blue and Orange

If you just want to always use system colors, you can force the ToolStrip to stop picking colors based off the theme globally by:

ToolStripManager.VisualStylesEnabled = false;

Or per-toolstrip:

ProfessionalColorTable professionalColorTable = new ProfessionalColorTable();
professionalColorTable.UseSystemColors = true;
toolStrip1.Renderer = new ToolStripProfessionalRenderer(professionalColorTable);

Matching Visual Studio's scheme

Here's a sample of how to replace a color table in your ToolStripProfessionalRenderer so you can get away from the stock blue colors if blue is not your thing.

The main concept here is that the ToolStripProfessionalRenderer creates Pens and Brushes based on a color table that is replacable. By inheriting from the ProfessionalColorTable, you can change all of the 40 some odd colors available to you.

The code to set in the tan color table is:

ToolStripManager.Renderer = new ToolStripProfessionalRenderer(new TanColorTable());

Or you can specify one specific toolstrip's renderer:

ToolStrip.Renderer = new ToolStripProfessionalRenderer(new TanColorTable());

Note that if you are a package within Visual Studio, the Visual Studio Core team still recommends using the Command Bar technology - this allows your toolbars to feed into the commanding system as well as their extensibility model.  If your code lives in Visual Studio and after careful consideration you feel you must use a ToolStrip, try fetching the "VsRenderer" or the "VsColorTable" out of the IUIService.Styles dictionary. The PropertyGrid has a new protected property which allows you to specify a custom renderer.

Hope this helps you get started!

Comments

  • Anonymous
    November 06, 2005
    Ah, the blue toolbars. Quite possibly the worst thing ever to come out of the Office UI team.

    The VS team makes a wise decision to use a tan/gray instead. Yet at the same time, makes a poor decision to have WinForms use the icky blue by default.
  • Anonymous
    November 06, 2005
    The comment has been removed
  • Anonymous
    November 09, 2005
    Yeah, you guys aren't really at fault. It's those folks at Office, they could use a stern talking to...
  • Anonymous
    November 11, 2005
    The comment has been removed
  • Anonymous
    November 12, 2005
    Interesting - thanks for pointing out about mage, it probably has an old copy of the color table. Royale was one of the last color schemes we supported - this tool might not have been updated. We'll take a look.

    This is pretty much the same code that the PropertyGrid in Visual Studio uses to match the rest of the Visual Studio Toolbars.
  • Anonymous
    November 25, 2005
    Is it possible to use the TanColorTable without any license or is some kind of permission required?
  • Anonymous
    November 28, 2005
    Its just like any other sample code on blogs.msdn.com.
  • Anonymous
    December 01, 2005
    Yes, yes, yes! If you are building a VSIP Package please use the standard Visual Studio command bars instead of the ToolStrip control. We have a ton of documentation on how to do this easily in the <a href="http://msdn.microsoft.com/vstudio/extend/">Visual Studio SDK</a>.
  • Anonymous
    March 07, 2006
    If you've read the ToolStrip FAQ, you may already be aware that you can replace the colors of the ToolStrip...