eventargs

Are EventArg classes needed now that we have generics

With generics, is there ever a reason to create specific derived EventArg classes It seems like now you can simply use them on the fly with a generic implementation. Should i go thorugh all of my examples and remove my eventArg classes (StringEventArgs, MyFooEventArgs, etc . .) public class EventArgs<T> : EventArgs { public EventA...

asp.net :how to use eventargs for parameter passing on button onclick?

i have seen some code in which people pass parameter through commandParameter Property of web control.then what is use of eventargs. ...

C# Custom EventArgs Question

Hi all, I have a custom collection that I am adding a ValidateItem event to. This ValidateItem event will be called whenever an item is added to or updated in the custom collection. I want to allow derived classes to be able to subscribe to the event and determine their own logic for whether or not an item is "valid" and potentially pr...

How wrong is it to create an event handler delegate with out the standard (Obj sender, EventArgs args) signature?

I understand the benefits of using the standard MS event handler delegate signature as it allows you to easily expand on the information passed through the event with out breaking any old relationships that are based on the old delegate signature. What I'm wondering is in practice how often do people follow this rule? Say I have a simpl...

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<System.EventArgs> MyCustomEvent; I do not plan on adding any event arguments to this event, but it is possible that any code could need to cha...

WPF: I don't understand class TextCompositionEventArgs

I don't understand the class TextCompositionEventArgs. There are members of type string named ControlText,SystemText,Text. Then there is a field TextConmposistion which itself contains the members ControlText, SystemText and Text again and additionally the fields SystemCompositionText and CompositionText. public class TextCompositionE...

LinkButton not accessing EventArg

Hello all, I am using c#.net. I am trying to create a LinkButton within the code-behind, when I debug my code I recieve no errors, however its not accessing the EventArg attached to the button, it does however refresh the page. What am I doing wrong? Button Code LinkButton myLinkButton = new LinkButton(); myLinkButton.ID = appointm...

How do EventArgs Cancel work in the FormClosing Event?

How does the e.Cancel event work in the FormClosing event on a WinForm? I know you set it to True to cancel the closing, but at what point does the form process this? Is there a secondary action taken by the property? How could I implement a similar action in a custom control? (C# or VB) Note: I've looked for about 30 minutes now and ...

Can you set EventArgs from ASP.NET controls?

I have a DropDownList whose SelectedIndexChanged event I set: move.SelectedIndexChanged += Move; public void Move(object sender, EventArgs e) { } I'd like to create a class derived from EventArgs which is the argument "e" that gets passed to the Move method. public void Move(object sender, EventArgs e) { MyEventArgs my_e = (MyEven...

Can someone please explain to me in the most layman terms how to use EventArgs?

I know they have something to do with delegates. I've tried but I still don't comprehend how to use those either. I know a little about event handlers but what I really want to know is how I can use plain old eventargs that are part of most methods. example below void Page_Load(object sender, EventArgs e) { myText.Value = "Hello Worl...

Problems with, or best practices for, passing data back through eventargs?

I've got a non-GUI class that generates events as to what it is doing (which are in turn used by a Form to display to the user the progress). One of the events is a AboutToDoSomethingDestructiveEvent. Now we want to have the Form display a dialog to the user when AboutToDoSomethingDestructiveEvent is raised, asking them if they would l...

how to deal with multiple event args

Hi all, I am in the process of creating a small game. The engine will have a number of events that the GUI can subscribe to. The events are: ballselected balldeselected ballmoved ballremoved This would all be fine if I only had one type of ball, but there are X number ball types. They all derive from an abstract Ball class. Each...

How do I make an eventhandler run asynchronously?

I am writing a Visual C# program that executes a continuous loop of operations on a secondary thread. Occasionally when that thread finishes a task I want it to trigger an eventhandler. My program does that but the when the event handler is triggered, the secondary thread waits until the event handler is finished before continuing the th...

.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 EventArgs());// EDIT: Yes it should be // handler(this,...

How to Instantiate a Custom EventArgs Class that has no Accessible Constructor?

I have a problem; I'm using an external library where one particular event has its own custom eventargs; with no constructor. If I want to throw my own event using these eventargs, how can I? I'll give more detail if asked, but I'm not sure what exactly I should be giving. :) ...

Publish Event Pass two textbox text as EventAgrs

Can i pass two string as eventargs on a button click internal void OnSaveComm(string strTitle,string strLink) { WorkItem.EventTopics[EventTopicNames.AgentRecentComm].Fire(this,new EventArgs<> XYZ,WorkItem,Microsoft.Practices.CompositeUI.EventBroker.PublicationScope.Global); } Using Event broker to pass string to subscr...

event args assigning

i have this event handler Temp.MouseLeftButtonDown += new MouseButtonEventHandler(Temp_MouseLeftButtonDown); but i wanna send some parameter to access in the Temp_MouseLeftButtonDown function. how can i assign it ?? ...

Does .NET have a built-in EventArgs<T>?

I am getting ready to create a generic EventArgs class for event args that carry a single argument: public class EventArg<T> : EventArgs { // Property variable private readonly T p_EventData; // Constructor public EventArg(T data) { p_EventData = data; } // Property for EventArgs argument public...

Why does CompositionTarget.Rendering take EventArgs instead of RenderingEventArgs?

The CompositionTarget.Rendering event is a plain old EventHandler, with a plain old EventArgs. However, in real life, it apparently always gets an instance of RenderingEventArgs. So your event handler has to start by casting the EventArgs in order to get the useful information out of them. Why isn't the event of type EventHandler<Render...

C# Serialize EventArgs to Xml

I am trying to serialize an object that contains an EventArgs object. If I ignore the EventArgs object upon serialization, everything works fine, but if I don't put an [XmlIgnore] above it, the application crashes with the error message System.InvalidOperationException was unhandled Message=There was an error generating the XML docume...