Simple question. I have a panel with 3 components. All of them are have Align := alRight. But the problem is that during runtime the order of them is not the same as designtime.
Can I instead use alCustom to force the order at the right border ? I use D2007.
Yes, you can do any type of custom alignment. Just use the control's OnAlignInsertBefore() and OnAlignPosition() events. (These exist in Delphi 2007, but aren't published so they don't appear in the Object Inspector's Events tab; you can still assign them in code. I've shown the prototypes below; they're documented in the help file under TAlignInsertBeforeEvent and TAlignPositionEvent; you can also see CustomAlignInsertBefore and OnAlignInsertBefore. )
TAlignInsertBeforeEvent = function(Sender: TWinControl;
C1, C2: TControl): Boolean of object;
TAlignPositionEvent = procedure(Sender: TWinControl; Control: TControl;
var NewLeft, NewTop, NewWidth, NewHeight: Integer;
var AlignRect: TRect; AlignInfo: TAlignInfo) of object;
The documentation contains pretty good descriptions of the parameters to both methods.
In Delphi 2010, these events are published and appear in the Events tab of the Object Inspector.
I've never seen the problem you're having, though... Did you try setting all of them to alNone, moving them away from the right edge, and then re-setting Align := alRight in the order you want them to appear?
Have a look at Demo2 from this download.
You don't reveal much of the problem at hand, but I would have taken a look at the flowpanel instead.
When dropping controls on a flowpanel, a new order-property 'automagically' appear. You can set which way your controls should flow, and if you want space between the controls, you set the margins on each control.
A little clearification: The new 'order-property' is actually called 'ControlIndex', and will appear at the bottom of the object inspector.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With