|
-
Sep 2nd, 2010, 01:10 PM
#1
Thread Starter
Addicted Member
CustomGroupBox Drawing
I have a Custom Groupbox that overrides the OnPaint event to do some custom drawing, backgrounds, etc. The problem I have is that when I use it in an application and want to draw text on the control, it gets drawn first, then immediately afterwards the OnPaint from the control gets called and draws on top of the text. Is there any way to get the text drawn after the control's OnPaint?
-
Sep 3rd, 2010, 12:41 AM
#2
Re: CustomGroupBox Drawing
First up, OnPaint is a method, not an event. The OnPaint method raises the Paint event. When you override an "On" method such as OnPaint, you always call the base method to actually raise the event, e.g.
vb.net Code:
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) 'Whatever you put here gets done BEFORE the Paint event is raised. MyBase.OnPaint(e) 'Whatever you put here gets done AFTER the Paint event is raised. End Sub
If you want something done before the event is raised and handled then you put the code before the base method call. If you want something done after the event is raised and handled then you put the code after the base method call.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|