K
kpg
vs 2005 vb.net windows form app.
Doing a simple gradient background on a form:
Protected Overrides Sub OnPaintBackground(ByVal e As
System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
Dim r As Rectangle = ClientRectangle
Dim b As Brush = New System.Drawing.Drawing2D.LinearGradientBrush
(r, Color.Gray, Color.Black,
System.Drawing.Drawing2D.LinearGradientMode.Vertical)
e.Graphics.FillRectangle(b, ClientRectangle)
End Sub
Problem:
On form resize the background is not painted properly. When increasing the
width the gradient is not re-drawn, it is just extended (the 2nd color is
painted in the new area exposed). When increasing height the newly exposed
area is drwan properly but the old ard is not re-drawn.
The client rectangle used in the paint event covers the entire form, so why
is it not re-drawing the form?
Thanks,
kpg
Doing a simple gradient background on a form:
Protected Overrides Sub OnPaintBackground(ByVal e As
System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
Dim r As Rectangle = ClientRectangle
Dim b As Brush = New System.Drawing.Drawing2D.LinearGradientBrush
(r, Color.Gray, Color.Black,
System.Drawing.Drawing2D.LinearGradientMode.Vertical)
e.Graphics.FillRectangle(b, ClientRectangle)
End Sub
Problem:
On form resize the background is not painted properly. When increasing the
width the gradient is not re-drawn, it is just extended (the 2nd color is
painted in the new area exposed). When increasing height the newly exposed
area is drwan properly but the old ard is not re-drawn.
The client rectangle used in the paint event covers the entire form, so why
is it not re-drawing the form?
Thanks,
kpg