Questions tagged [eventargs]

Represents the base class for classes that contain event data, and provides a value to use for events that do not include event data.

Represents the base class for classes that contain event data, and provides a value to use for events that do not include event data.

This class serves as the base class for all classes that represent event data. For example, the System.AssemblyLoadEventArgs class derives from EventArgs and is used to hold the data for assembly load events. To create a custom event data class, create a class that derives from the EventArgs class and provide the properties to store the necessary data. The name of your custom event data class should end with EventArgs.

http://msdn.microsoft.com/en-us/library/system.eventargs(v=vs.110).aspx

164 questions
12
votes
2 answers

Should an Event that has no arguments define its own custom EventArgs or simply use System.EventArgs instead?

I have an event that is currently defined with no event arguments. That is, the EventArgs it sends is EventArgs.Empty. In this case, it is simplest to declare my Event handler as: EventHandler MyCustomEvent; I do not plan on…
Mike Rosenblum
  • 12,027
  • 6
  • 48
  • 64
8
votes
3 answers

.NET: Is creating new EventArgs every time the event fires a good practice?

For example, I have a base event publishing method: protected virtual OnSomeEvent(EventArgs e) { var handler = SomeEvent; if (handler != null) { handler(this, e); // handler(this, new…
Dan7
  • 1,657
  • 1
  • 19
  • 31
8
votes
2 answers

Get sender name event handler

I hope the name gives justice to my question... So, I just started making a memory game, and there are 25 checkbox buttons which I am using to show the items. I was wondering whether there was a way to tell from either the EventArgs or the Object…
Mathias
  • 213
  • 2
  • 4
  • 7
6
votes
1 answer

Why no constraint on EventHandler?

I just figured out by accident (when something compiled that I didn't think would compile) that EventHandler is not constrained to the type System.EventArgs. Here's the inline docs: #region Assembly mscorlib.dll, v4.0.0.0 // C:\Program Files…
Aaron Anodide
  • 16,906
  • 15
  • 62
  • 121
6
votes
5 answers

Jquery - Pass asp button command argument with jquery

I have asp button: and script: $("a").click(function () { var val = $(this).attr('id').toString(); …
Muno
  • 749
  • 2
  • 9
  • 19
5
votes
3 answers

Is there a special association between the EventArgs class and the event keyword?

In all the .NET book I've read the guide line for implementing events explains that you need to subclass EventArgs and use EventHandler. I looked up more info on http://msdn.microsoft.com/en-us/library/ms229011.aspx, and it says "Do use…
smartcaveman
  • 41,281
  • 29
  • 127
  • 212
5
votes
2 answers

My class cannot be used as type parameter 'TEventArgs' in the generic type or method 'System.EventHandler' in .Net 4

I have trying to learn about EventHandler and I have to use a notification project. Here is the link of project : https://codeload.github.com/mike-eason/WPF_ToastNotifications/zip/master All I did is changing .Net-framework from 4.5 to 4 And I faced…
arna
  • 53
  • 5
4
votes
4 answers

How to do I return an item from a custom event handler

A project I'm working on requires me to be able to fire off an event everytime an item is added to a list. To achieve this, I created a custom List class inheriting from List and added a OnAdd event. I also want to return the item being added as…
Ayush
  • 41,754
  • 51
  • 164
  • 239
4
votes
1 answer

Get the "Text" value out of "System.EventArgs objArgs"

As you can see in that screenshot in "objArgs" there is a property "Text". How can I reach that property?
Bayern
  • 330
  • 3
  • 20
4
votes
1 answer

Proper usage of EventArgs

I have a pretty basic event: public event EventHandler OnAborted; All I need to do is call this event, I don't even need to provide any arguments, so it's nothing fancy. I'm confused with the correct usage of the EventArgs argument. I can use: if…
Mike Eason
  • 9,525
  • 2
  • 38
  • 63
3
votes
2 answers

Custom Events in ASP.NET

I want to handle a custom event on an asp.net page with C# as my code Behind. I want to increase the size of the search text box on clicking it. It should be somewhat like this... I know this can be done using event and delegate.I tried something,…
Pavitar
  • 4,282
  • 10
  • 50
  • 82
3
votes
3 answers

How do you deal with "events" in a high-performance scenario?

Update: I wrote a program to test the memory implications of each of the techniques I mention below. Not too surprisingly, I found that, sure enough, the conventional approach using .NET events creates a lot more garbage than the other approaches…
Dan Tao
  • 125,917
  • 54
  • 300
  • 447
3
votes
1 answer

Registering event, why the code can compile without error?

I believe there should be many questions on SO related to this but I can't think of the proper keywords to search for them. The code class Subscriber { public Subscriber(Notifier n) { n.OnSomeEvent += (object sender, EventArgs e) =>…
kennyzx
  • 12,845
  • 6
  • 39
  • 83
3
votes
3 answers

Can't seem to Pass EventArgs By Reference

I have a class that raises an event. I want the subscriber to be able to modify the values being passed in the EventArgs. In the class that raises the events: class Factory { public event EventHandler
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
3
votes
1 answer

Implementing EventArgs Empty Correctly

I'm trying to properly understand Events and EventArgs but can't quite get a handle on the whole EventArgs.Empty property. EventArgs implements: public static readonly EventArgs Empty; and allows us to create an EventHandler and call it…
Storm
  • 1,848
  • 4
  • 20
  • 39
1
2
3
10 11