Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying To Understand Delegates
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01278832
Message ID:
01278880
Vues:
19
May be give you some more similar information.

This waste me 2 hrs for finding the right Keywords!!

+= EventHandler(xxxxx) does Click, DoubleClick, Enter, Leave, ...
+= KeyEventHandler(xxxxx) does KeyUp, KeyDown, KeyXXXX...
+= MouseEventHandler(xxxx) does MouseUp, MouseWheel, ...

I donno KeyEventHandler, waste a lot of time to try but simple.


>Thanks. althought I'm still sorta fuzzy. Sorry for the confusion. I'm still looking C# throughg the lens of VFP.
>
>See my notes in line.
>
>
>
>// I understand this. It's the event declaration
>public event EventHandler MyFooBar;
>
>// I get this
>if (this.MyTextBox.Text == "FOO")
>
>      // I looked up the EventArgs class on MSDN. It states:
>      //
>      // "This class contains no event data; it is used by events that do not pass state
>      // information to an event handler when an event is raised. If the event handler
>      // requires state information, the application must derive a class from this class
>      // to hold the data."
>      //
>      // So this creates and passes a default EventArgs class because OnMyFooBar
>      // takes an EventArgs parameter, correct?
>	this.OnMyFooBar(new EventArgs());
>
>
>// Lastly, this raises the MyFooBar event:
>protected virtual void OnMyFooBar(EventArgs e)
>{
>        // This is don't get at all. MyFooBar is an event definition. How can it be Null?
>        // What would make it not null?
>	if MyFooBar != null)
>		MyFooBar(this, e);
>}
>
>
>
>This I need help with:
>
>
>
>// Can you translate this into english for me?
>this.oMyControl.MyFooBar += new System.EventHandler(this.oMyControl_MyFooBarHandler);
>
>// This is the function to run when the event is raised, correct?
>private void oMyControl_MyFooBarHandler(object sender, System.EventArgs e)
>{
>	// whatever your code needs to be
>}
>
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform