Click here to Skip to main content
15,902,299 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Table creation in VB.NET Pin
Naji El Kotob20-Jul-07 3:08
Naji El Kotob20-Jul-07 3:08 
GeneralRe: Table creation in VB.NET Pin
JonCox20-Jul-07 4:29
JonCox20-Jul-07 4:29 
Questionhow to make viewback color of a propertygrid transparent Pin
MartyK200719-Jul-07 22:47
MartyK200719-Jul-07 22:47 
AnswerRe: how to make viewback color of a propertygrid transparent Pin
Dave Kreskowiak20-Jul-07 7:26
mveDave Kreskowiak20-Jul-07 7:26 
GeneralRe: how to make viewback color of a propertygrid transparent Pin
MartyK200722-Jul-07 21:09
MartyK200722-Jul-07 21:09 
GeneralRe: how to make viewback color of a propertygrid transparent Pin
Dave Kreskowiak23-Jul-07 3:29
mveDave Kreskowiak23-Jul-07 3:29 
GeneralRe: how to make viewback color of a propertygrid transparent Pin
MartyK200723-Jul-07 4:00
MartyK200723-Jul-07 4:00 
GeneralRe: how to make viewback color of a propertygrid transparent Pin
Dave Kreskowiak23-Jul-07 12:04
mveDave Kreskowiak23-Jul-07 12:04 
MartyK2007 wrote:
Protected Overrides Sub OnPaintBackground(ByVal pevent As PaintEventArgs)
MyBase.OnPaintBackground(pevent)
Dim g As Graphics = pevent.Graphics
Dim gradBrush As System.Drawing.Drawing2D.LinearGradientBrush
gradBrush = New System.Drawing.Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(Me.Width, Me.Height), Color.Green, Color.Blue)
' g.FillRectangle(gradBrush, 0, 0, Me.Width, Me.Height)
g.FillRectangle(gradBrush, pevent.ClipRectangle)

End Sub


First, you don't create your own Graphics object. You'll find it in the PaintEventArgs that you're getting when your code is called.
Dim g As Graphics = pevent.Graphics

Your next mistake is that if you want to REPLACE the background functionality, you don't call the base classes OnPaintBackground method. That will paint the background of the control just like you didn't even attempt to make your own version of it.
Third, the Graphics objects to DID create, you didn't Dispose of. This will, most assuredly, run your machine out of resources and your app will eventully crash with an OutOfMemoryException. On top of that, if you didn't create the object, like Graphics, you do NOT Dispose of it.


A guide to posting questions on CodeProject[^]

Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007


GeneralRe: how to make viewback color of a propertygrid transparent Pin
MartyK200723-Jul-07 21:17
MartyK200723-Jul-07 21:17 
GeneralRe: how to make viewback color of a propertygrid transparent Pin
Dave Kreskowiak24-Jul-07 1:48
mveDave Kreskowiak24-Jul-07 1:48 
GeneralRe: how to make viewback color of a propertygrid transparent Pin
MartyK200724-Jul-07 2:19
MartyK200724-Jul-07 2:19 
QuestionConnectionStrings & Using UNC Paths Offline Pin
NekoGato19-Jul-07 21:55
NekoGato19-Jul-07 21:55 
AnswerRe: ConnectionStrings & Using UNC Paths Offline Pin
Colin Angus Mackay19-Jul-07 23:53
Colin Angus Mackay19-Jul-07 23:53 
QuestionRichtextbox MaxLength Pin
NANCO19-Jul-07 21:43
NANCO19-Jul-07 21:43 
AnswerRe: Richtextbox MaxLength Pin
Colin Angus Mackay19-Jul-07 23:50
Colin Angus Mackay19-Jul-07 23:50 
AnswerRe: Richtextbox MaxLength Pin
cutequencher20-Jul-07 5:13
cutequencher20-Jul-07 5:13 
QuestionHoe to connect crystal report with db dynamically? Pin
help as an alias19-Jul-07 21:04
help as an alias19-Jul-07 21:04 
AnswerRe: Hoe to connect crystal report with db dynamically? Pin
Rupesh Kumar Swami20-Jul-07 0:44
Rupesh Kumar Swami20-Jul-07 0:44 
GeneralRe: Hoe to connect crystal report with db dynamically? Pin
help as an alias20-Jul-07 0:53
help as an alias20-Jul-07 0:53 
GeneralRe: Hoe to connect crystal report with db dynamically? Pin
Rupesh Kumar Swami20-Jul-07 1:15
Rupesh Kumar Swami20-Jul-07 1:15 
GeneralRe: Hoe to connect crystal report with db dynamically? Pin
help as an alias20-Jul-07 2:26
help as an alias20-Jul-07 2:26 
QuestionLoad MyApplication on Windows Startup Pin
teebonaire19-Jul-07 19:32
teebonaire19-Jul-07 19:32 
AnswerRe: Load MyApplication on Windows Startup Pin
Ky Nam19-Jul-07 21:14
Ky Nam19-Jul-07 21:14 
GeneralRe: Load MyApplication on Windows Startup Pin
teebonaire19-Jul-07 21:35
teebonaire19-Jul-07 21:35 
GeneralRe: Load MyApplication on Windows Startup Pin
Ky Nam20-Jul-07 2:17
Ky Nam20-Jul-07 2:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.