|
-
Jun 5th, 2006, 08:17 PM
#1
Thread Starter
Arabic Poster
[RESOLVED] System.EventArgs e
Hi everybody,
I have a question, What is the use of the object included in all event handlers?
I have never seen any code that uses it, it even doesn't have any usefull properties or methods within.
I found about 200 subclasses but I guess each one is related to a different event.
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jun 5th, 2006, 08:35 PM
#2
Re: System.EventArgs e
It is convention that every event handler has two arguments: an Object and an EventArgs. The first argument is always the object that raised the event and the second argument is always the data for the event. If the event has no data then an EventArgs object is used, basically as a place-holder for consistency. If the event does have some data then a different type that inherits EventArgs is used, which will add the members appropriate for the events it will be used for. For instance, the CancelEventArgs class inherits the EventArgs class and adds the Cancel property, which is used in various events including FormClosing.
-
Jun 5th, 2006, 08:54 PM
#3
Thread Starter
Arabic Poster
Re: System.EventArgs e
so, basically, the EventArgs class is useless!!
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jun 5th, 2006, 08:57 PM
#4
Re: System.EventArgs e
 Originally Posted by ComputerJy
so, basically, the EventArgs class is useless!!
No it's not. It's the base class for every other class that is used as a second argument for an event handler.
-
Jun 5th, 2006, 09:01 PM
#5
Thread Starter
Arabic Poster
Re: System.EventArgs e
OK, sorry.
I meant to say "the object included in all general event handlers is useless
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jun 5th, 2006, 09:10 PM
#6
Re: System.EventArgs e
Have you read the MSDN documentation for the EventArgs class? As I've posted many times, that should be the first stop:
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.
Like I said, it is used for consistency, so that all event handlers have consistent signatures.
-
Jun 5th, 2006, 09:14 PM
#7
Thread Starter
Arabic Poster
Re: [RESOLVED] System.EventArgs e
Thanks (I have to spread some reputation points) LOL
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|