Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
On Methods Question
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01414827
Message ID:
01414839
Vues:
44
>In .Net there are methods that start with 'On', such as OnPaint, OnResize.
>
>I know I can call thes methods, but I know very little about them. What are they, when do you use them, and what's the correct way to invoike them - meaning how do you create a propert event args class for the method you're calling?
>
>My form automatically calls OnPaint at certain times, and anytime I call Invalidate(), but if I wanted to call it on my one (or would i?), how do you get the correct arguments?

The form calls OnPaint anytime it wants to raise the Paint event.
If you could see inside the base class the OnPaint() method would probably look like this:
protected void OnPaint(PaintEventArgs e)
{
     if (Paint !=null)
        Paint(this,e);
}
If you override it then you would need to supply an instance of PaintEventArgs which requires a System.Drawing.Graphics object and a Rectangle (http://msdn.microsoft.com/en-us/library/system.windows.forms.painteventargs_members.aspx)

If you want to actually raise the Paint event then you need to include base.OnPaint(e) in the method so that the above code executes.
HTH,
Viv
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform