开发者

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 c开发者_如何学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.


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.


If you want to scroll vertically set

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


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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜