Re: Applying color to Toolbars

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Ken Tucker [MVP] (vb2ae_at_bellsouth.net)
Date: 05/01/04


Date: Sat, 1 May 2004 18:27:41 -0400

Hi,

    Try this.

   //
   // TODO: Add constructor logic here
   //
   this.SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true);

Ken
--------------------
"Tonny" <anonymous@discussions.microsoft.com> wrote in message
news:305748E6-DB6A-4C9A-8B18-A6C3ECFFD94B@microsoft.com...
> Hi
>
> I'm trying to draw an gradient on a Toolbar. I have created my own
> GradientToolbar, which inherrits from Toolbar. In this I try to override
> OnPaint in order to draw something:
>
> protected override void OnPaint(PaintEventArgs e)
> {
> Rectangle rectangle = new Rectangle(0, 0, this.Width, this.Height);
> Color gradientColorA = Color.Blue;
> Color gradientColorB = Color.White;
> Brush brush = new LinearGradientBrush(rectangle, gradientColorA,
> gradientColorB, 0.0F);
> e.Graphics.FillRectangle(brush, rectangle);
> }
>
> However, nothing happens. The toolbar is not drawn with the desired
> colors.
>
> Is there anyone who knows how to draw the background of an toolbar. I
> obviously don't. I have also tried to override the BackColor - also
> without an positive result.
>
> If anyone have an answer to how to solve this problem I would be
> gratefull, if you respond to this message.
>
> Kind regards,
> Tonny



Relevant Pages

  • Re: Applying color to Toolbars
    ... Now I'm able to draw a gradient "backcolor". ... > GradientToolbar, which inherrits from Toolbar. ... >> protected override void OnPaint ...
    (microsoft.public.dotnet.framework.drawing)
  • Applying color to Toolbars
    ... I'm trying to draw an gradient on a Toolbar. ... I have created my own GradientToolbar, ... In this I try to override OnPaint in order to draw something: ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Owner drawn menus, XP or MS Outlook
    ... I sub-classed the toolbar and that seems to allow me to apply a gradient. ... > Either buy a third-party library or roll up your sleeves and do it all ... > Find great Windows Forms articles in Windows Forms Tips and Tricks ...
    (microsoft.public.dotnet.framework.drawing)
  • RE: BackgroundImage in ToolBar
    ... ToolBar.BackGroundImage can not add a background image to the Toolbar, ... To draw a background image on the toolbar is not easy, ... For further information on toolbar custom draw, ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: How can I add horizontal white stripes through fonts?
    ... and none of your posts explain clearly enough ... toolbar and buttons are you using to try to draw a line? ... Select Line from the Drawing toolbar, ... >>> would like to draw several horizontal white lines through bold black ...
    (microsoft.public.word.drawing.graphics)