Results 1 to 7 of 7

Thread: [RESOLVED] System.EventArgs e

  1. #1

    Thread Starter
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Resolved [RESOLVED] System.EventArgs e

    Hi everybody,
    I have a question, What is the use of the
    VB Code:
    1. e As System.EventArgs
    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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: System.EventArgs e

    Quote 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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
  •  



Click Here to Expand Forum to Full Width