logo       

Re: Handling lots of menu entries: msg#00417

windows.devel.dotnet.winforms

Subject: Re: Handling lots of menu entries

Richard Heintze schrieb:

How would this work if I am using the Forms Designer
(aka Dialog Editor)? I would create my 10 menu itmes
and for a single menu item double click on to create
an event for just that menu entry and go back and edit
the other to add the same event to the other menu
entries using the overloaded "+="?

As Andy said: use the designer to select the same handler for each item.

Where would I do this? In the constructor for the
Form?

This is also a possibility.

Ok, so what do I do in the event hander? Would it look
like this?

MenuItem * pMI = (MenuItem*)sender;
if(pMI == miOpacity100) Opacity = 1.0;
else if (pMI == miOpacity90) Opacity=.9;
else if (pMI == miOpacity80) Opacity=.8;
...

For example (no need for the cast, though). Or you use an appropriate
data structure to map menu items to float values.

Fabian



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise