How can I change the order of ToolButtons in a inheritable form?

843 views Asked by At

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?

1

There are 1 answers

0
J... On BEST ANSWER

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.