Home All Groups Group Topic Archive Search About

How to associate a menuItem and a toolbarbutton?

Author
12 Apr 2007 2:17 PM
supermonkey
As we all known, a menuItem often has a corresponding toolbar button in a
windows form program.

I want to associate a menuItem with corresponding toobarbutton which has the
same action with it. So that when I check a menuItem, the toolbarbutton will
also looks like "pressed".

In MFC, we call achieve this purpose by seting them to the same ID, but how
to implement this in C#??


Thank you very much!

Author
12 Apr 2007 4:58 PM
Nicholas Paldino [.NET/C# MVP]
Unfortunately, there is nothing out of the box that does this.  What you
are looking for is the command pattern, where you have objects which
represent actions, and triggering an action where the state of the command
is updated will be reflected in all UI elements which are bound to the
command.

    You are going to have to implement something like this in .NET yourself,
or, if you are fortunate enough, develop in WPF, as it has a very rich
command infrastructure.

    Hope this helps.

--
          - Nicholas Paldino [.NET/C# MVP]
          - mvp@spam.guard.caspershouse.com

Show quoteHide quote
"supermonkey" <supermon***@mail.nankai.edu.cn> wrote in message
news:e02HH1QfHHA.2332@TK2MSFTNGP04.phx.gbl...
> As we all known, a menuItem often has a corresponding toolbar button in a
> windows form program.
>
> I want to associate a menuItem with corresponding toobarbutton which has
> the same action with it. So that when I check a menuItem, the
> toolbarbutton will also looks like "pressed".
>
> In MFC, we call achieve this purpose by seting them to the same ID, but
> how to implement this in C#??
>
>
> Thank you very much!
>
Are all your drivers up to date? click for free checkup

Author
13 Apr 2007 2:16 AM
Jay Mitchell
http://msdn.microsoft.com/msdnmag/issues/02/10/CommandManagement/default.aspx
demonstrates this approach.

Bookmark and Share