Dynamically change the toolbar?

Hi all,

I have a quick question. Maybe I am missing something here, but is there a way to dynamically replace a toolbar with another one?

For example, say that I have two tabs: Members and Notes

If the user clicks on the “Members” tab, the members toolbar should be shown. However, if the user selects the “Notes” tab, the notes toolbar should display.

What is the recommend way to approach this?

Thank you!

Byron

One idea is to use the same toolbar and dynamically remove the irrelevant buttons and replace them with the one for the relevant tabs.

Here is a dirty example (it’s not the best coding but you can clean it up yourself). In this example, I set up the toolbar with two buttons at the offset, each time you change the tab, the second button change.

This is the code that does the magic, I called it setToolBarButtons which accepts the tab index.

toolbar11.removebuttonAt(1)


var newbutton as new DesktopToolbarButton

if index = 1 then
  
  newbutton.Caption = "Set 2"
  newbutton.Name = "btn1"
  newbutton.ButtonStyle = DesktopToolbarButton.buttonstyles.PushButton
  
  
else
  newbutton.Caption = "Set 1"
  newbutton.Name = "btn1"
  newbutton.ButtonStyle = DesktopToolbarButton.buttonstyles.PushButton
  
end if 

toolbar11.AddButtonAt(1,newbutton)

In the TabPanel’s PanelChanged() events, the code I use is

setToolBarButtons(me.SelectedPanelIndex)

I am sure there are other ways to do this but hope that gets your juices flowing.

1 Like

If the user clicks on the “Members” tab, the members toolbar should be shown.

if you have 2 toolbars in one window you can exchange the visibility

A

ToolbarA.Visible=True
ToolbarB.Visible=False

B

ToolbarA.Visible=False
ToolbarB.Visible=True
1 Like

That works but each time you change tabs, the height of the window increases.

1 Like

How about having to toolbar contain all of the items and only having the relevant ones visible?

1 Like

Thanks for the good insights! Much appreciated… :slight_smile:

Byron