简体   繁体   English

FMX firemonkey如何在运行时滚动垂直滚动框

[英]FMX firemonkey how to Scroll a vertical scroll box in runtime

Somebody can help me how to scroll a vertical scrollbar in firemonkey in runtime, there is a property scrollby, but it didnt work, I don't have any ideia how to solve it.有人可以帮助我如何在运行时在 firemonkey 中滚动垂直滚动条,有一个属性 scrollby,但它不起作用,我不知道如何解决它。

Thanks谢谢

There is no independent vertical scroll bar component in FMX. FMX 中没有独立的垂直滚动条组件。 There are however several scroll box components.然而,有几个滚动框组件。 A TVertScrollbox (VSB) is one of them. TVertScrollbox (VSB) 就是其中之一。 If you use that, you can safely set VSB.Align:= TAlignlayout.Client .如果你使用它,你可以安全地设置VSB.Align:= TAlignlayout.Client The VSB never scrolls itself. VSB 从不滚动自身。 It only scrolls the content if the content exceeds the vertical dimension of the VSB.如果内容超过 VSB 的垂直尺寸,它只会滚动内容。

You can put a TLayout on the VSB, then set it's alignment to VertCenter , and it's Height to VSB.Height * 2 .您可以在 VSB 上放置一个TLayout ,然后将其 alignment 设置为VertCenter ,并将其Height设置为VSB.Height * 2 At runtime, the vertical scrollbar will appear, and you will be able to scroll the layout up and down.在运行时,会出现垂直滚动条,您将能够上下滚动布局。 After this, you can adjust the position of the layout on the screen by calling the Scrollby and ViewPortPosition methods of the VSB.在此之后,您可以通过调用VSB的ScrollbyViewPortPosition方法来调整屏幕上布局的position。

Use a TScrollBox set TAlignlayout.Client then put the components inside the Tscrollbox and set them TAlignlayout.top and Done.使用TScrollBox设置TAlignlayout.Client然后将组件放入Tscrollbox并将它们设置为TAlignlayout.top和 Done。 When the content exceeds the vertical dimension the scroll will appear.当内容超过垂直尺寸时,将出现滚动。

in delphi and C ++ Builder in FMX you can use ScrollBy (int, int);在 FMX 中的 delphi 和 C ++ Builder 中,您可以使用 ScrollBy (int, int); to move the scroll移动卷轴

Exemple:示例:

      this->ScrollBox->ScrollBy(0, - this->ScrollBox->Width);

I used a negative value because this will make the scroll move downwards following the pre-filling of items.我使用了负值,因为这会使滚动在预填充项目后向下移动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM