Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can't Get Form's Paint Method To Work...
Message
From
27/11/2006 16:36:30
Alexandre Palma
Harms Software, Inc.
Alverca, Portugal
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01172750
Message ID:
01172766
Views:
11
Hi Ben insdead of handling the form.paint event you will need to override it.
Try this
Protected Overrides Sub OnPaint(e As PaintEventArgs)
      ' Call the OnPaint method of the base class.
      MyBase.OnPaint(e)
      ' Call methods of the System.Drawing.Graphics object.
      '***************************************
      ' Initialize Variables
      '***************************************
      Dim brushBlueGradient As LinearGradientBrush
      '***************************************
      ' Default Values
      '***************************************
      brushBlueGradient = New LinearGradientBrush(Me.ClientRectangle, _
                                                  Color.FromArgb(115, 160, 196), _
                                                  Color.FromArgb(194, 213, 224), _
                                                   LinearGradientMode.Vertical)
      '***************************************
      ' Draw Main Gradient Area
      '***************************************
      e.Graphics.FillRectangle(brushBlueGradient, New Rectangle(0, 0, Me.ClientSize.Width, Me.ClientSize.Height))   
End Sub
>I have the following code placed inside an MDI Parent Form's Paint method:
>
>
>    Private Sub frmMain_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
>
>        '***************************************
>        ' Initialize Variables
>        '***************************************
>        Dim brushBlueGradient As LinearGradientBrush
>
>        '***************************************
>        ' Default Values
>        '***************************************
>        brushBlueGradient = New LinearGradientBrush(Me.ClientRectangle, _
>                                                    Color.FromArgb(115, 160, 196), _
>                                                    Color.FromArgb(194, 213, 224), _
>                                                    LinearGradientMode.Vertical)
>
>        '***************************************
>        ' Draw Main Gradient Area
>        '***************************************
>        e.Graphics.FillRectangle(brushBlueGradient, New Rectangle(0, 0, Me.ClientSize.Width, Me.ClientSize.Height))
>    End Sub
>
>
>Yet when it runs, the MDI Parent's background is not changed. What am I missing?
>
>Thanks for any help that can be offered.
Alexandre Palma
Senior Application Architect
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform