Click here to Skip to main content
16,007,277 members
Home / Discussions / C#
   

C#

 
GeneralGetOpenFileName in C# Pin
Formato6-Feb-05 9:01
Formato6-Feb-05 9:01 
GeneralRe: GetOpenFileName in C# Pin
Heath Stewart7-Feb-05 6:15
protectorHeath Stewart7-Feb-05 6:15 
GeneralEvents and delegates: help! Pin
Gleb Belov6-Feb-05 4:55
Gleb Belov6-Feb-05 4:55 
GeneralRe: Events and delegates: help! Pin
mav.northwind6-Feb-05 5:12
mav.northwind6-Feb-05 5:12 
GeneralRe: Events and delegates: help! Pin
Gleb Belov6-Feb-05 5:37
Gleb Belov6-Feb-05 5:37 
GeneralRe: Events and delegates: help! Pin
Skynyrd6-Feb-05 6:17
Skynyrd6-Feb-05 6:17 
GeneralEventHandler question! Pin
QzRz6-Feb-05 1:50
QzRz6-Feb-05 1:50 
GeneralRe: EventHandler question! Pin
mav.northwind6-Feb-05 3:11
mav.northwind6-Feb-05 3:11 
I think you have a misconception of what event handlers are.
An event handler is just a callback (look up 'delegate' on MSDN) that is called by the class that publishes the event.
Each event handler has a certain signature, usually containing the object calling the delegate and an additional object holding some additional information for the event.

The Click event of System.Windows.Forms.Button (or rather the matching event handler delegate System.EventHandler) has such a signature. Because System.Windows.Forms.Button calls the delegate you give it, there's nothing you can do to modify the signature of the delegate there.
So you'd have to derive from Button and override the Click event not to require an event handler of type EventHandler but one of type MyNewEventHandler.
This delegate would be declared like this:
public delegate void MyNewEventHandler(object sender, System.EventArgs e, int something, bool whatever);

In your derived class you'll have to fire your new Click event by calling the event handlers attached to your new button class.

You see, it's not quite as easy as you might expect.

Are you sure your button can (or should) provide the additional information in the Click event? Are something and whatever really different with each click?

If not then you shouldn't change the event handler signature for something as basic as a click event.

Mav
GeneralRe: EventHandler question! Pin
Heath Stewart6-Feb-05 7:24
protectorHeath Stewart6-Feb-05 7:24 
Generalcreate a Byte[] array Pin
Sasuko6-Feb-05 0:19
Sasuko6-Feb-05 0:19 
GeneralRe: create a Byte[] array Pin
Robert Rohde6-Feb-05 0:56
Robert Rohde6-Feb-05 0:56 
GeneralRe: create a Byte[] array Pin
Sasuko6-Feb-05 1:27
Sasuko6-Feb-05 1:27 
Generalremote user name Pin
Opa Knack6-Feb-05 0:12
Opa Knack6-Feb-05 0:12 
GeneralRe: remote user name Pin
Heath Stewart6-Feb-05 7:21
protectorHeath Stewart6-Feb-05 7:21 
QuestionCreating MMC snap-in? Pin
esjq5-Feb-05 23:33
esjq5-Feb-05 23:33 
AnswerRe: Creating MMC snap-in? Pin
Heath Stewart6-Feb-05 7:18
protectorHeath Stewart6-Feb-05 7:18 
GeneralRe: Creating MMC snap-in? Pin
esjq6-Feb-05 20:53
esjq6-Feb-05 20:53 
Generalupdate doesn't update database Pin
xrado5-Feb-05 23:14
xrado5-Feb-05 23:14 
GeneralRe: update doesn't update database Pin
Heath Stewart6-Feb-05 7:10
protectorHeath Stewart6-Feb-05 7:10 
GeneralEditing custom file formats Pin
Gleb Belov5-Feb-05 22:48
Gleb Belov5-Feb-05 22:48 
GeneralRe: Editing custom file formats Pin
Robert Rohde5-Feb-05 23:31
Robert Rohde5-Feb-05 23:31 
GeneralRe: Editing custom file formats Pin
Gleb Belov6-Feb-05 3:41
Gleb Belov6-Feb-05 3:41 
GeneralRe: Editing custom file formats Pin
mav.northwind6-Feb-05 3:51
mav.northwind6-Feb-05 3:51 
GeneralRe: Editing custom file formats Pin
Gleb Belov6-Feb-05 4:04
Gleb Belov6-Feb-05 4:04 
GeneralRe: Editing custom file formats Pin
Dave Kreskowiak7-Feb-05 4:08
mveDave Kreskowiak7-Feb-05 4:08 

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.