Multiple Event Handlers for Single Event

G

Guest

Hi All,

I have an issue where I'd like a single global event to be handled by
multiple event handlers. In this case, I would like a "global" (static) Menu
Item that I create in a class, and I'd like the controls that use this menu
to each react to its Click event.

Perhaps I've been spending too much time in the sun?

Thanks,
pagates
 
N

Nicholas Paldino [.NET/C# MVP]

Pagates,

This isn't a good idea from a design perspective. If you have a
MenuItem, then it most surely has to be attached to a menu, either a context
menu, or a menu on a form. Regardless, the event should be scoped to these
instances, not globally.

What exactly are you trying to do?
 
G

Guest

Hi Nicholas,

I have a number of controls that contain ListViews. Some of these controls
are seen at the same time. The requirement is that there is a context menu
item that allows the user to choose (globally) whether certain columns are
visible. One menu selection needs to update all the lists on all the
controls.

I know that I could have a separate context menu in each control, have it
fire an event to the wrapper control, which in turn would set a property or
call a method to set the visible columns in each of the other controls, but
that seems risky too (for instance, if the choices are changed down the road,
etc.). It seems like a central event could be "cleaner".

Thanks,
PAGates


Nicholas Paldino said:
Pagates,

This isn't a good idea from a design perspective. If you have a
MenuItem, then it most surely has to be attached to a menu, either a context
menu, or a menu on a form. Regardless, the event should be scoped to these
instances, not globally.

What exactly are you trying to do?

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

pagates said:
Hi All,

I have an issue where I'd like a single global event to be handled by
multiple event handlers. In this case, I would like a "global" (static)
Menu
Item that I create in a class, and I'd like the controls that use this
menu
to each react to its Click event.

Perhaps I've been spending too much time in the sun?

Thanks,
pagates
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top