Handles vs. Overrides

  • Thread starter Thread starter YYZ
  • Start date Start date
Y

YYZ

I have a usercontrol that I want to paint myself. What is the
difference between these 2 methods of handling the painting?

Private Sub ucLoanDisplay_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles MyBase.Paint

vs.

Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)

I think I'm missing something big here in understanding .Net.

Thanks!

Matt
 
Handles is used to tell .NET that you want this sub to handle a particular
event, in your case the Paint event.

Overrides in this case replaces the default functionality of the Paint event
for the control.
 
Back
Top