Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object Sender and EventArgs

Consider this function signature:

Private Void TextBox1_TextChange(Object Sender, EventArgs e)

As far as my knowledge goes I understand it as below.

  1. Private is a modifier

  2. Void is the return type

  3. TextBox1_TextChange is an event name.

Maybe I am wrong in the above case as I just started practicing in C#, Visual Studio 2005.

What is the definition/meaning of (Object Sender, EventArgs e) and how does it work?

like image 995
mahesh Avatar asked Sep 08 '10 07:09

mahesh


People also ask

What is object sender and EventArgs in C#?

The C# Object sender is one of the argument, and it's a parameter for creating the reference of the object which has been raised for the events that are used for to respond the handler to mapping the correct object but in case of static parameters or events, the value will be null with the help of EventArgs class we ...

What is EventArgs?

EventArgs is also the class you use when an event does not have any data associated with it. When you create an event that is only meant to notify other classes that something happened and does not need to pass any data, include the EventArgs class as the second parameter in the delegate. You can pass the EventArgs.

What is sender As object E as EventArgs in VB net?

Sender is the object that raised the event and e contains the data of the event. All events in . NET contain such arguments. EventArgs is the base class of all event arguments and doesn't say much about the event.

What base class do you use to convey information for an event?

EventArgs is a base class for conveying information for an event.


2 Answers

TextChange is (probably) the name of the relevant event, though the event isn't shown in your code snippet so I can't be sure.

TextBox1_TextChange is the name of a method that is probably set up to handle an event.

Object Sender is a parameter called Sender that contains a reference to the control/object that raised the event.

EventArgs e is a parameter called e that contains the event data, see the EventArgs MSDN page for more information.

See this page, Passing Parameters, for more information about how parameters work.

And this page, Events Tutorial, would probably be helpful as well.

like image 57
Hans Olsson Avatar answered Oct 29 '22 22:10

Hans Olsson


Object Sender: which object is invoked the current event.in your case TextBox1 is sender. EventArgs e :e is the object for EventArgs, when TextChange is invoked object e contain arguments.

like image 44
Vyasdev Meledath Avatar answered Oct 30 '22 00:10

Vyasdev Meledath