473,387 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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!
Apr 12 '07 #1
2 1512
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]
- mv*@spam.guard.caspershouse.com

"supermonkey" <su*********@mail.nankai.edu.cnwrote in message
news:e0**************@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!

Apr 12 '07 #2
http://msdn.microsoft.com/msdnmag/is...t/default.aspx
demonstrates this approach.

Apr 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Rakesh | last post by:
Hi, I am able to obtain a MenuItem object's Name property @ design-time, but am not able to get the same @ run- time...why? And since MenuItem doesn't inherit from Control class, it's not...
6
by: Claus Holm | last post by:
I'm trying to enable a menuitem in the parent form from a mdichild. Rather than making the menuitems public, I'd go for a public method in the parent form to do the change, but when I call the...
2
by: Peter Rilling | last post by:
It seems to me that the ToolBarButton should be a control, but instead it inherits from Component. Is there a reason this could not have inherited from Control since really a ToolBarButton is...
0
by: Brian Binnerup | last post by:
Hi. I am using the ms:ToolBar control on one of our products, and now a customer whishes for it to be with a dark blue background - I can do that by specifying a style on the ms:ToolBar tag -...
5
by: Barry Gast | last post by:
Hi. I am trying to access the names of the toolbar buttons in order to match to correct button name passed to a function. However, there is no ..Name property on a ToolBarButton control. Is...
6
by: Eric Sabine | last post by:
Basically, the following code creates a menuItem array and tries to use it twice. In the following piece of code, only the line that appears second gets used. The first becomes ignored presumably...
4
by: Ahmed | last post by:
Hi everyone, Is there a way to add a toolbarbutton with dropdown menu similar to the mail button in IE? In another word, when the chevron is part of the button not beside it. Thanks Ahmed
0
by: Steven | last post by:
Hi, I have a toolbar control with several buttons in ToolBarButton class. How can I change the text color of the ToolBarButton control in VB.NET 2003? Thanks! Steven
2
by: polocar | last post by:
Hi, I'm writing a program using Visual C# 2005 Professional Edition, and I was trying to assign multiple MainMenu objects (one by one, of course) to the same Form (let's suppose 2 MainMenu...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.