Why use 'Protected Overrides Sub OnPaint'?

Mateus

Active member
Joined
Apr 16, 2010
Messages
27
Programming Experience
3-5
Hi All,

A real noob question here that hopefully has a simple answer!

Why, when drawing graphics, do most online guides recommend using Protected Overrides Sub OnPaint (ByVal e As PaintEventArgs) rather then the standard paint call an object? :uncomfortableness:

I'm drawing graphics (bitmaps, lines, squares, etc) but whether I put the code in Form1_Paint or in the above doesn't seem to matter.

So why should I use Protected Overrides Sub OnPaint (ByVal e As PaintEventArgs)?

Cheers,
M.
:peaceful:
 
Ok... but I realise this all relates to inheritance but what is the advantage of overriding the OnPaint handle if an object already has Paint functions (e.g. PictureBoxes, Forms and Labels)? :ambivalence:

Thanks,
M.
 
Last edited:
That is already explained in that article, if you create derived classes use the protected On-methods internally, externally there is no other option than to handle the event.
 
Back
Top