Alin Sfetcu
Alin Sfetcu

Reputation: 542

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.

Upvotes: 6

Views: 8936

Answers (3)

Jacek Krawczyk
Jacek Krawczyk

Reputation: 2184

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;

Upvotes: 2

Mike Taylor
Mike Taylor

Reputation: 2524

If you want to scroll vertically set

FlowPanel1.Align := alTop;
FlowPanel1.AutoSize := True;
FlowPanel1.AUtoWrap := False;

Upvotes: 4

Deltics
Deltics

Reputation: 23036

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.

Upvotes: 14

Related Questions