Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

When writing events for classes should i use the OnEvent method to do my coding and leave the actual event for the user?

For instance OnPaint and Paint... when i paint my control.. which is the correct method to use? my guess would be onpaint... but i'm not sure why.

Also.. Is Me.Refresh the best way to repaint my form? or is there a faster way to accomplish the refresh of my form?

i think i may have asked that second question before...but something makes me feel that me.refresh isn't exactly the fastest way to do it.

i'm not lazy i'm just resting before i get tired.
  • *Gurus*
Posted

It doesn't make much difference whether you override OnPaint or listen for the Paint event, usually. The OnPaint function in the base class will do whatever default painting the control has, then it raises the Paint event. If you override OnPaint, the Paint event will never be raised. This is usually only an issue if you want people to be able to listen for your Paint event.

 

You can use .Refresh or .Invalidate to make your control redraw. I prefer Invalidate, because it doesn't force an immediate redraw, it just marks the surface as invalid so when windows next gets round to it, it will initiate the redraw itself. Also, you can pass a region or rectangle to Invalidate, and only that bit of the surface will be redrawn. This can increase drawing speed.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

cool thanks divil...

i noticed this post was moved... where did i put it to begin with? i could have sworn i put it in General

i'm not lazy i'm just resting before i get tired.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...