Results 1 to 2 of 2

Thread: CustomGroupBox Drawing

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2004
    Posts
    195

    Unhappy 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?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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:
    1. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    2.     'Whatever you put here gets done BEFORE the Paint event is raised.
    3.  
    4.     MyBase.OnPaint(e)
    5.  
    6.     'Whatever you put here gets done AFTER the Paint event is raised.
    7. 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width