B
Bryon
My current code paints a rectangular area at the top (under the menu and
tool strip) and bottom (top of the status strip) of the main form with a
linear gradient. The problem is that when the form is resized or maximized
for that matter, the form still displays the last areas that were painted
with gradient. Basically the form does not erase the last graphics that
were painted to the form and just paints over it with the new. My code is
as follows in the form paint event.
----------------------
Private Sub frmMain_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
'declare rectangle dimensions for areas to be painted. Areas will be 64
pixels high.
Dim rectTop As New Rectangle(0, (mainMenu.Height + tsSearchBar.Height),
Me.Width, 64)
Dim rectBottom As New Rectangle(0, (Me.Height - (64 +
ssMessages.Height)), Me.Width, 64)
'declare brushes for linear gradient.
Dim brushTop As New LinearGradientBrush(rectTop, Color.SlateGray,
Color.Transparent, LinearGradientMode.Vertical)
Dim brushBottom As New LinearGradientBrush(rectBottom,
Color.Transparent, Color.DarkGray, LinearGradientMode.Vertical)
'paint areas with gradients upon form refreshes and repaints
e.Graphics.FillRectangle(brushTop, rectTop)
e.Graphics.FillRectangle(brushBottom, rectBottom)
brushTop.Dispose()
brushBottom.Dispose()
End Sub
tool strip) and bottom (top of the status strip) of the main form with a
linear gradient. The problem is that when the form is resized or maximized
for that matter, the form still displays the last areas that were painted
with gradient. Basically the form does not erase the last graphics that
were painted to the form and just paints over it with the new. My code is
as follows in the form paint event.
----------------------
Private Sub frmMain_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
'declare rectangle dimensions for areas to be painted. Areas will be 64
pixels high.
Dim rectTop As New Rectangle(0, (mainMenu.Height + tsSearchBar.Height),
Me.Width, 64)
Dim rectBottom As New Rectangle(0, (Me.Height - (64 +
ssMessages.Height)), Me.Width, 64)
'declare brushes for linear gradient.
Dim brushTop As New LinearGradientBrush(rectTop, Color.SlateGray,
Color.Transparent, LinearGradientMode.Vertical)
Dim brushBottom As New LinearGradientBrush(rectBottom,
Color.Transparent, Color.DarkGray, LinearGradientMode.Vertical)
'paint areas with gradients upon form refreshes and repaints
e.Graphics.FillRectangle(brushTop, rectTop)
e.Graphics.FillRectangle(brushBottom, rectBottom)
brushTop.Dispose()
brushBottom.Dispose()
End Sub