I am trying to use TFlowPanel component in the following manner:
- Place on the main form
Form1
componentFlowPanel1: TFlowPanel
. - Set
Form1.Width = 400
,FlowPanel1.Align = alTop
,FlowPanel1.AutoSize = True
,FlowPanel1.AutoWrap = True
. - Place on the
FlowPanel1
5 SpeedButtons and set theirWidth
to 64. - Compile and run.
- Reduce width of the form (something about
Form1.Width = 200
).
For some reason, the speedbuttons do not automatically line up in two rows when user resizes the form. Although, they do line up in two rows when AutoSize = False
, AutoWrap = True
.
What is the reason for this behavior and how to solve it?
Edit: I've found "quick and dirty" solution. The following code is the event handler to the TFlowPanel.OnResize
event:
procedure TForm1.FlowPanel1Resize(Sender: TObject);
begin
with FlowPanel1 do
begin
AutoSize := False;
Realign; // line up controls
AutoSize := True; // adjust TFlowPanel.Height
end;
end;
However, I still wonder if there is a standard way to solve the problem.