Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Inherited label class and mouse events
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00873386
Message ID:
00873457
Vues:
24
Look at the OnMouseDown, OnMouseEnter, OnMouseHover, OnMouseLeave,
OnMouseMove, OnMouseUp, and OnMouseWheel protected methods. These methods get called whenever the event is raised.

So you would write something like this in your subclass:
protected void OnMouseDown(MouseEventArgs e)
{
   //Put whatever code you want here
   //Then call the event handlers
   base.OnMouseDown(e);
}
Note that "this" (or "me" for vb) refers to the form when you write an event handler for your control on a form. Using the override method above, "this" when placed in the OnWhateverEvent refers to the control (in your case the label).

The documentation tells you how to do it:
"The OnMouseDown method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Notes to Inheritors: When overriding OnMouseDown in a derived class, be sure to call the base class's OnMouseDown method so that registered delegates receive the event.
"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclassonmousedowntopic.asp

>Hello:
>
>I am programmatically creating labels from my own inherited label class. I need to create a mouse event for each new inherited label. My question is: can a programmatically created label inherit a mouse event. If not, how can I create a mouse event programmatically for each new label.
>
>Thanks,
>
>Steve Ellis
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform