Toolbar button groups

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I want to have a group of three buttons on my toolbar such that one and only one can be pushed in at a time. In other words, when you push one, the other two are up. When you push one of the two up ones, the one that was pushed comes up. I don't know the name of this behaviour or if it is doable. Is there a way to do this

Thank you
Joe
 
Hi Joe,
Those buttons are called "Radio Buttons". AFAIK toolbars and toolbar buttons
doesn't support radio features. You have to implement it by yourself. One
possible implementation is to set all button in the group to have Style =
ToolbarButtonStyle.ToggleButton. Then when receive ButtonClick event for
some of the buttons in the group set the Pushed property of the rest of the
buttons in the radio group to !e.Button.Pushed.

--
HTH
B\rgds
100

Joe Thompson said:
Hi,

I want to have a group of three buttons on my toolbar such that one and
only one can be pushed in at a time. In other words, when you push one, the
other two are up. When you push one of the two up ones, the one that was
pushed comes up. I don't know the name of this behaviour or if it is
doable. Is there a way to do this?
 
Hi

Thanks for the reply. I thought about implementing it myself but the problem is the user can still click on a button that is already down and it will come up leaving none pushed in. I always want one pushed in. Any ideas??

Joe
 
Yes, you are right.
Look at the following ButtonClick event handler

if(toolBarButton1 == e.Button)
{
toolBarButton1.Pushed = true;
toolBarButton2.Pushed = false;
toolBarButton3.Pushed = false;
}
else if(toolBarButton2 == e.Button)
{
toolBarButton2.Pushed = true;
toolBarButton1.Pushed = false;
toolBarButton3.Pushed = false;
}
else if(toolBarButton3 == e.Button)
{
toolBarButton3.Pushed = true;
toolBarButton2.Pushed = false;
toolBarButton1.Pushed = false;
}

However, I don't like suggesting such a solutions. If I were you I would go
with solution similar to the one suggested in this article.
http://msdn.microsoft.com/msdnmag/issues/02/10/CommandManagement/default.aspx
This is the idea built in MFC framework for example. Similar solutions can
be found in VCL, OWL 2 and I beleive in many other frameworks. Hopefully in
future this will be implemeted in Windows Froms as well eventhough I doubt
it.
--
HTH
B\rgds
100

Joe Thompson said:
Hi,

Thanks for the reply. I thought about implementing it myself but the
problem is the user can still click on a button that is already down and it
will come up leaving none pushed in. I always want one pushed in. Any
ideas???
 
Back
Top