|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to associate a menuItem and a toolbarbutton?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! 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. -- Show quoteHide quote- Nicholas Paldino [.NET/C# MVP] - mvp@spam.guard.caspershouse.com "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! >
http://msdn.microsoft.com/msdnmag/issues/02/10/CommandManagement/default.aspx
demonstrates this approach.
Other interesting topics
Process exits when reading a file which is being written
Disadvantages of C#??? just curious Picking off XML Elements About virtual and abstract method host a windows workflow problem FindByPrimaryKey(keyID) returns null Can not get cookies from a web page. Events firing when I don't want them to Enum - XmlEnum Generics Objects |
|||||||||||||||||||||||