Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
(C#) Raise an Event
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01016081
Message ID:
01016647
Views:
10
I don't understand what it is you want to do. You want to *generically* fire the event that is hooked up? I think this is not possible externally because the events are attached to single-cast delegates and you can't access them externally.

If you know what hte handler method is though you can directly call it which was my point before.

The approach you describe would work, but it's tough to implement in the WinForms designer because you'd basically have to rename the menu items manually after the designer's dumped them onto the form.

What I usually do in my forms is have a single menu/toolbar handler method. Call it MenuHandler which accepts a standard EventHandler signature so it can be hooked up from any menu and toolbar button.

The method then compares which member is passed in the sender parameter and based on that takes action. That way you can fire any of the handlers simply by passing the button and EventArgs. It also cuts down on the mess of event handler methods that get created usually with just a couple of lines of code in them.

This method can get large and unwieldy too, but I prefer this one method because it keeps the forms object model much simpler so you can actually find stuff with the Class Viewer <g>...

>
>That's exactly what I want to try. I can only think of one way to do this. Subclass MenuItem, and add a public member, we'll call it .FireOnPopup. .FireOnPopup would call the protected MenuItem.OnPopup. Is that the right way to do this?
>
>Thanks,
>Mike
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform