|
Re: Handling lots of menu entries: msg#00415windows.devel.dotnet.winforms
No, you can do that all from the form designer. Just use the same method name for the DoubleClick event for each MenuItem. The designer is smart enough to know that the function already exists, so it'll use the same function for each menu item. Andy -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:DOTNET-WINFORMS@xxxxxxxxxxxxxxxxxxx] On Behalf Of Richard Heintze Sent: Saturday, February 28, 2004 3:44 PM To: DOTNET-WINFORMS@xxxxxxxxxxxxxxxxxxx Subject: Re: [DOTNET-WINFORMS] Handling lots of menu entries 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 "+="? Where would I do this? In the constructor for the Form? If I edit the InitializeComponent funciton generated by the Dialog editor, do I also have to edit that .resX file whose format I don't understand? The InitializeComponent function seems the logical place to do it (if it does not crash that dialog editor). 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; ... Ugghhh! What do you think? Is that a significant improvement over having a seperate event handler for each menu item? Is there a better way? Sieg --- Fabian Schmied <fabian.schmied@xxxxxx> wrote: > Richard Heintze schrieb: > > > I wanted to add the ability to change the opacity > to > > my GUI app. I added a 10 of menu entries with 10 handlers. It was > > grotesque! Is there a better way? > > > > void Form1::Opacity100(System::Object* s, > > System::EventArgs* e){ > > Opacity = 1.0; > > } > > void Form1::Opacity90(System::Object* s, > > System::EventArgs* e){ > > Opacity = .9; > > } > > void Form1::Opacity80(System::Object* s, > > System::EventArgs* e){ > > Opacity = .8; > > } > > Yes, I believe you should be able to create one event handler and > check the "sender" argument ("s" in your code). > > Fabian __________________________________ Do you Yahoo!? Get better spam protection with Yahoo! Mail. http://antispam.yahoo.com/tools |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | How to store/retrieve PictureBox in MSAccess database: 00415, Richard Heintze |
|---|---|
| Next by Date: | Re: How to store/retrieve PictureBox in MSAcces s database: 00415, Booth, Bill |
| Previous by Thread: | Re: Handling lots of menu entriesi: 00415, Richard Heintze |
| Next by Thread: | Re: Handling lots of menu entries: 00415, Fabian Schmied |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |