Click here to Skip to main content
15,921,660 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to remove whitespace(<\p> )using stringbuilder in c# Pin
raj2313624-Nov-08 21:49
raj2313624-Nov-08 21:49 
Questionhow To Add Product key Setup Pin
Piyush Vardhan Singh4-Nov-08 18:39
Piyush Vardhan Singh4-Nov-08 18:39 
AnswerRe: how To Add Product key Setup Pin
leppie4-Nov-08 20:58
leppie4-Nov-08 20:58 
QuestionRegisterHotKey help Pin
MeekLogic4-Nov-08 18:30
MeekLogic4-Nov-08 18:30 
QuestionSet a license screen in deployment of Window based project. Pin
sumit70344-Nov-08 17:36
sumit70344-Nov-08 17:36 
AnswerRe: Set a license screen in deployment of Window based project. Pin
cyber-drugs5-Nov-08 0:29
cyber-drugs5-Nov-08 0:29 
QuestionReading Message from MSMQ and DIsplaying Pin
honeyss4-Nov-08 17:31
honeyss4-Nov-08 17:31 
AnswerRe: Reading Message from MSMQ and DIsplaying Pin
Jimmanuel5-Nov-08 1:06
Jimmanuel5-Nov-08 1:06 
QuestionPrint screen including the cursor image working except for IBeam cursor Pin
xax4-Nov-08 15:59
xax4-Nov-08 15:59 
AnswerRe: Print screen including the cursor image working except for IBeam cursor Pin
xax8-Nov-08 14:32
xax8-Nov-08 14:32 
QuestionDouble Pin
dec824-Nov-08 14:48
dec824-Nov-08 14:48 
AnswerRe: Double Pin
DaveyM694-Nov-08 15:13
professionalDaveyM694-Nov-08 15:13 
QuestionMessage Closed Pin
4-Nov-08 10:22
razikang4-Nov-08 10:22 
AnswerCP Ignore - spamming the site Pin
Dave Kreskowiak4-Nov-08 10:36
mveDave Kreskowiak4-Nov-08 10:36 
AnswerREPORTED AS ABUSE Pin
leckey4-Nov-08 14:26
leckey4-Nov-08 14:26 
QuestionDirectoryInfo functionality for http paths Pin
kenrentz4-Nov-08 10:14
kenrentz4-Nov-08 10:14 
QuestionHow do I create a generic .Net event handler Pin
astibich24-Nov-08 9:59
astibich24-Nov-08 9:59 
I am attempting to write code that sinks an event with only an object reference and the event name - no type information. I write a generic event handler function:


public void ComponentEventHandler(object o, EventArgs e)
{
// handle generic event
}


Then I wrote some code that attaches any event to this event handler function


protected void SinkControlEvent(Control ctrl, string eventName)
{
EventDescriptor event = TypeDescriptor.GetEvents(ctrl)[eventName];
Delegate del = Delegate.CreateDelegate(typeof(System.EventHandler), this, "ComponentEventHandler");
event .AddEventHandler(ctrl, del);
}

This works fine when the event I'm sinking has the standard function signature. However, I get an exception when the event has a derived EventArgs parameter. For example, trying to sink the following event would cause a type mismatch exception:

public event void ValueChanged(object sender, ValueEventArgs e);

The exception is "Invalid event handler for ValueChanged event". Of course 'ValueEventArgs' inherits from EventArgs, so I don't understand why this isn't a valid handler.

Some things to note:

1. You can, in code, assign an untyped event handler to a typed event. Somehow the compiler figures it out.
2. I tried changing my code such that I attach an untyped function to a typed delegate, but that also threw an exception.

Delegate del = Delegate.CreateDelegate(event.EventType, this, "ComponentEventHandler");


Thanks,

Aaron Stibich
AnswerRe: How do I create a generic .Net event handler Pin
Pete O'Hanlon4-Nov-08 11:51
mvePete O'Hanlon4-Nov-08 11:51 
GeneralRe: How do I create a generic .Net event handler Pin
Mark Churchill4-Nov-08 12:27
Mark Churchill4-Nov-08 12:27 
GeneralRe: How do I create a generic .Net event handler Pin
Pete O'Hanlon4-Nov-08 22:22
mvePete O'Hanlon4-Nov-08 22:22 
QuestionOverriding a Dictionary's Item property Pin
Clive D. Pottinger4-Nov-08 8:37
Clive D. Pottinger4-Nov-08 8:37 
AnswerRe: Overriding a Dictionary's Item property Pin
led mike4-Nov-08 9:23
led mike4-Nov-08 9:23 
GeneralRe: Overriding a Dictionary's Item property Pin
Clive D. Pottinger4-Nov-08 9:33
Clive D. Pottinger4-Nov-08 9:33 
AnswerRe: Overriding a Dictionary's Item property Pin
Wendelius4-Nov-08 9:25
mentorWendelius4-Nov-08 9:25 
GeneralRe: Overriding a Dictionary's Item property Pin
Clive D. Pottinger4-Nov-08 9:38
Clive D. Pottinger4-Nov-08 9:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.