Hi group,

I manage with toolBars.
This class seems to me as a prehsitorical (if that word exists) class to
me......
I used the class ToolBar, added ToolBarButton in the ToolBar.Buttons, put
images on them etc....

To detect a ToolBarBbutton.Click event, it seems that the only way is to
detect the ToolBar.Click event then to determine the ID of the Button
clicked, and select do what to do in a great switch case.
That mean that if i insert a new button to my ToolBar during a maintenance
developpement, or for a new version, i will have to rewrite my entiere
switch case !

Is there a realist method to get my ToolBarButton.click events ??
In the ToolBarButtonCollection, I can fix the name of myToolBarsButtons, so
why can't i access them with it ?
Must i develop a new ToolBarButton class to do that ?
Or is there a real third part ToolBar class wich improve some realist
functionalities ?
Or do i miss something ?

thanks
ROM

Re: Fuc@#!! ToolBars by Scott

Scott
Fri Oct 24 09:33:58 CDT 2003

I haven't used Toolbars in .NET, but in VB 6.0 you could assign each
particular button a "Key" value (for example the "New" button would have a
key of "New", etc.). This way, if/when you modify your toolbar and add a
button, all you have to do in your case statement is add 1 more Case
statement that checks for that new buttons "Key".

Select Case Button.Key
Case "New"
code
Case "Open"
code
Case "Print"
code
End Case

-Scott

"Romain TAILLANDIER" <romain.taillandier@mfactories.com> wrote in message
news:O8OcJGhmDHA.964@TK2MSFTNGP10.phx.gbl...
> Hi group,
>
> I manage with toolBars.
> This class seems to me as a prehsitorical (if that word exists) class to
> me......
> I used the class ToolBar, added ToolBarButton in the ToolBar.Buttons, put
> images on them etc....
>
> To detect a ToolBarBbutton.Click event, it seems that the only way is to
> detect the ToolBar.Click event then to determine the ID of the Button
> clicked, and select do what to do in a great switch case.
> That mean that if i insert a new button to my ToolBar during a maintenance
> developpement, or for a new version, i will have to rewrite my entiere
> switch case !
>
> Is there a realist method to get my ToolBarButton.click events ??
> In the ToolBarButtonCollection, I can fix the name of myToolBarsButtons,
so
> why can't i access them with it ?
> Must i develop a new ToolBarButton class to do that ?
> Or is there a real third part ToolBar class wich improve some realist
> functionalities ?
> Or do i miss something ?
>
> thanks
> ROM
>
>
>
>
>



Re: Fuc@#!! ToolBars by Alan

Alan
Fri Oct 24 10:09:08 CDT 2003


"Scott M." <s-mar@badspamsnet.net> wrote in message
news:utoHUwjmDHA.3700@TK2MSFTNGP11.phx.gbl...
> I haven't used Toolbars in .NET, but in VB 6.0 you could assign each
> particular button a "Key" value (for example the "New" button would have a
> key of "New", etc.). This way, if/when you modify your toolbar and add a
> button, all you have to do in your case statement is add 1 more Case
> statement that checks for that new buttons "Key".

It's the same in .NET. But the OP is right. The toolbars shipped with VS
are a joke and prehistoric is a good word for them. If you want the latest
bells and whistles for toolbars there are vendors that sell good solutions.
Dockable, source code, etc.

-- Alan



Re: Fuc@#!! ToolBars by Joerg

Joerg
Sat Oct 25 09:06:10 CDT 2003

"Alan Pretre" wrote:

>
> "Scott M." <s-mar@badspamsnet.net> wrote in message
> news:utoHUwjmDHA.3700@TK2MSFTNGP11.phx.gbl...
> > I haven't used Toolbars in .NET, but in VB 6.0 you could assign
> > each particular button a "Key" value (for example the "New" button
> > would have a key of "New", etc.). This way, if/when you modify
> > your toolbar and add a button, all you have to do in your case
> > statement is add 1 more Case statement that checks for that new
> > buttons "Key".
>
> It's the same in .NET. But the OP is right. The toolbars shipped
> with VS are a joke and prehistoric is a good word for them. If you
> want the latest bells and whistles for toolbars there are vendors
> that sell good solutions. Dockable, source code, etc.

A better approach than switching is storing a MenuItem or Button
reference that invokes the same UI action in the ToolBarButton's Tag
property. This reduces the tool bar click handler to:

private void OnToolBarButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e) {
MenuItem menuItem = e.Button.Tag as MenuItem;
if (menuItem != null) {
menuItem.PerformClick();
return;
}
Button button = e.Button.Tag as MenuItem;
if (button != null) {
button.PerformClick()
}
}

Cheers,
--
Joerg Jooss
joerg.jooss@gmx.net

Re: Fuc@#!! ToolBars by Christopher

Christopher
Sat Oct 25 19:16:09 CDT 2003

Hi Rom,

I agree that it is pretty bad.
One way you could get around it is to attach a new event handler to the
ToolBar for each button,
creating multiple subscribers for the event.
Each event handler checks if the repspective button is pressed.

toolBar1.ButtonClick += new
ToolBarButtonClickEventHandler(ToolBarButton1_Clicked);
toolBar1.ButtonClick += new
ToolBarButtonClickEventHandler(ToolBarButton2_Clicked);

private void ToolBarButton1_Clicked(object sender,
ToolBarButtonClickEventArgs e)
{
if(e.Button == ToolBarButton1)
{
// do something here
}
}

private void ToolBarButton2_Clicked(object sender,
ToolBarButtonClickEventArgs e)
{
if(e.Button == ToolBarButton2)
{
// do something here
}
}

Hope this helps.

Chris

"Romain TAILLANDIER" <romain.taillandier@mfactories.com> wrote in message
news:O8OcJGhmDHA.964@TK2MSFTNGP10.phx.gbl...
> Hi group,
>
> I manage with toolBars.
> This class seems to me as a prehsitorical (if that word exists) class to
> me......
> I used the class ToolBar, added ToolBarButton in the ToolBar.Buttons, put
> images on them etc....
>
> To detect a ToolBarBbutton.Click event, it seems that the only way is to
> detect the ToolBar.Click event then to determine the ID of the Button
> clicked, and select do what to do in a great switch case.
> That mean that if i insert a new button to my ToolBar during a maintenance
> developpement, or for a new version, i will have to rewrite my entiere
> switch case !
>
> Is there a realist method to get my ToolBarButton.click events ??
> In the ToolBarButtonCollection, I can fix the name of myToolBarsButtons,
so
> why can't i access them with it ?
> Must i develop a new ToolBarButton class to do that ?
> Or is there a real third part ToolBar class wich improve some realist
> functionalities ?
> Or do i miss something ?
>
> thanks
> ROM
>
>
>
>
>



Re: Fuc@#!! ToolBars by Romain

Romain
Mon Oct 27 03:14:24 CST 2003

thanks all for all this usefull responds...

ROM



"Romain TAILLANDIER" <romain.taillandier@mfactories.com> a écrit dans le
message de news: O8OcJGhmDHA.964@TK2MSFTNGP10.phx.gbl...
> Hi group,
>
> I manage with toolBars.
> This class seems to me as a prehsitorical (if that word exists) class to
> me......
> I used the class ToolBar, added ToolBarButton in the ToolBar.Buttons, put
> images on them etc....
>
> To detect a ToolBarBbutton.Click event, it seems that the only way is to
> detect the ToolBar.Click event then to determine the ID of the Button
> clicked, and select do what to do in a great switch case.
> That mean that if i insert a new button to my ToolBar during a maintenance
> developpement, or for a new version, i will have to rewrite my entiere
> switch case !
>
> Is there a realist method to get my ToolBarButton.click events ??
> In the ToolBarButtonCollection, I can fix the name of myToolBarsButtons,
so
> why can't i access them with it ?
> Must i develop a new ToolBarButton class to do that ?
> Or is there a real third part ToolBar class wich improve some realist
> functionalities ?
> Or do i miss something ?
>
> thanks
> ROM
>
>
>
>
>