4

I have two forms. The first one has a TToolBar and two TToolButton. The second one inherits the first one and has three more TToolButton. I change the order of the buttons in design time, putting the three buttons of the second form before the buttons of the first form. When the application is running, the buttons of the second form appear after the buttons of the first form.

Is there a way to use the order set in design time?

  • I have no delphi at hand here, but have you tried moving every toolbutton in design time, also the ones from the parent form ? Maybe that could force the designer to write each position in the dfm file – GuidoG Jan 11 '18 at 13:45
  • I tried to move every button. The ones in parent form are aways show before the ones in the child form, no matter what position I set in child form. – Lucas Felipe Silva Jan 11 '18 at 15:48

1 Answers1

6

No, there is no way to override the position of buttons inherited from the ancestor form. Buttons on a TToolBar are contained in a simple TList and are added in the order that they are created. They are created in the order that they appear in the .dfm file and, when inheriting a form, the ancestor's controls are always created and added first.

Even if you reorder the buttons at design time, save the form, and then close and re-open it the layout will only preserve the ordering changes to the descendent form's toolbar buttons with the ancestor buttons reappearing at the beginning again.

This is a limitation of the TToolBar class itself. Your options are to either write a custom toolbar or to manage the button arrangement programmatically.

J...
  • 30,968
  • 6
  • 66
  • 143