Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I scroll the content of a TFlowPanel?

Delphi implementation of the TFlowPanel control seems to lack an important feature of the C# version, the AutoScroll one.

The C# control with AutoWrap= False and AutoScroll=True behave like a horizontal scrollable list of controls.

How can i mimic the behavior of the C# version of the control ?

Thanks, Alin

P.S. I know i can use TScrollBox to get this behavior but TFlowPanel (in the not crippled version) allow for much more flexibility.

like image 541
Alin Sfetcu Avatar asked Jul 15 '10 09:07

Alin Sfetcu


3 Answers

Create your TFlowPanel inside a TScrollBox, with the following properties:

  • Align : alLeft
  • AutoSize : TRUE
  • AutoWrap : FALSE

That should get you the behaviour you are after I think.

like image 169
Deltics Avatar answered Sep 21 '22 11:09

Deltics


If you want to scroll vertically set

FlowPanel1.Align := alTop;
FlowPanel1.AutoSize := True;
FlowPanel1.AUtoWrap := False;
like image 26
Mike Taylor Avatar answered Sep 22 '22 11:09

Mike Taylor


For people who are looking for a working vertical scrolling method:

procedure TfrmSample.FixVerticalScroll(const AFloatPanel: TFloatPanel);
begin
  fFloatPanel.Align := alTop;
  fFloatPanel.AutoSize := True;
  fFloatPanel.AutoWrap := True;
  fFloatPanel.OnResize := OnFlowPanelResize;
end;

procedure TfrmSample.OnFlowPanelResize(Sender: TObject);
begin
  // Fix: otherwise panel is not operating on the full width
  fFloatPanel.Align := alClient;
  fFloatPanel.Align := alTop;
end;
like image 22
Jacek Krawczyk Avatar answered Sep 18 '22 11:09

Jacek Krawczyk