Flickering of gradient rectangle



Hello,

I created an panel in my form. In the Paint event of this panel I
created a gradient rectangle...
Like you can see in this code:

Rectangle rect = new Rectangle(0, 0, this.panel1.Width,
this.panel1.Height);

LinearGradientBrush m_brush = new LinearGradientBrush(rect,
SystemColors.Highlight, SystemColors.GradientInactiveCaption,
LinearGradientMode.ForwardDiagonal);

e.Graphics.FillRectangle(m_brush, rect);

PointF left = new PointF(0, this.panel1.Height - 1);
PointF right = new PointF(this.panel1.Width, this.panel1.Height - 1);

e.Graphics.DrawLine(SystemPens.ControlLightLight, left, right);

In the form constructur I already set these styles:
SetStyle(ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.DoubleBuffer, true);
UpdateStyles();

The problem is that when I resize the window (in my test app the panel
is docked in the form) the gradient rectangle is flickering. What I
want is a rectangle that is resizing when I resize my form. But without
flickering...

Can somebody help me!?

Greetings!
LW

.



Relevant Pages

  • Make child controls take gradient background of parent panel
    ... The trouble is when I place controls onto the panel their background colour ... just takes that background colour of the panel, not the drawn gradient. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Using (Create)Graphics outside Paint event
    ... gradient fill, containing the text of title application. ... can use a label or draw directly to the panel surface on the Paint ... You know, the label in CF is not transparent, so I get a small ... Paint event for that panel. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Gradient Backgrounds
    ... > background for something like a panel? ... Basically I have some 3rd party controls that have gradient ... brush and fill the control's region in its 'OnPaint' method or 'Paint' ... event handler. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Gradient Backgrounds
    ... background for something like a panel? ... I don't want to resort to using XP-themes (so that it'll run on pre-XP ... Basically I have some 3rd party controls that have gradient ... (Auckland | Aotearoa) ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Flickering of gradient rectangle
    ... But is still flickers when I resize ... public partial class PanelEx: Panel ... flags and use this control to draw your gradient... ... The problem is that when I resize the window (in my test app the panel ...
    (microsoft.public.dotnet.framework.windowsforms)

Loading