What is the BackColor of a ToolStrip control

I have put a ToolStrip control onto my form, it's colour is a nicely shaded light blue at the top to a darker blue at the bottom.

At run time if I inspect the BackColor property it is:
 "{Name=Control, ARGB=(255, 236, 233, 216)}" which for my XP Theme is a gray colour.

Now if I change the color to say Color.Blue then I lose the shading a get a solid blue BackColor.
If I try to revert the BackColor to it's original value the ToolStrip is a flat plain grey with no shading.

How do I change the color of the ToolStrip control and keep the color gradient of the control?
LVL 6
openshacAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Wayne Taylor (webtubbs)Connect With a Mentor AstronautCommented:
Hi openshac,

The BackColor of the Toolstrip control accepts flat colors only. To set the BackColor to it's original state, set the BackColor to Color.Empty....

    toolStrip1.BaclColor = Color.Empty;

To apply a Gradient to the Toolstrip, you'll need handle the Paint event....

     private void ToolStrip1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
     {
         System.Drawing.Drawing2D.LinearGradientBrush lgb = new System.Drawing.Drawing2D.LinearGradientBrush(e.ClipRectangle, Color.Blue, Color.LightBlue, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
         e.Graphics.FillRectangle(lgb, e.ClipRectangle);
     }

Regards,

Wayne
0
 
openshacAuthor Commented:
Great answer.
0
All Courses

From novice to tech pro — start learning today.