Scrolling Programmatically THorzScrollBox Firemonkey XE6

不羁岁月 提交于 2019-12-11 11:48:10

问题


I have a THorzScrollBox in a form, and some TStyledControls inside. Each StyledControl has a Tag to identify. Using an TEdit to inform a value, I can find inside the ScrollBox an specific Control by his tag.

If the control that I searched is not on the screen, I want to scroll the ScrollBox to show it.

How can I do this programmatically?


回答1:


I found a way to do this. I have to use ScrollBy. But the detail is that if I want to scroll the controls to right I have to use a negative value. Example:

sbItems.ScrollBy(-10, 0); // this will scroll to right

If I use a positive value, it will scroll to left.

sbItems.ScrollBy(10, 0); // this will scroll to left

The point is, if you scroll once, the ViewportPosition will change and the next time you execute ScrollBy, it will not reset the scroll position, it will scroll from the point you already have scrolled.



来源:https://stackoverflow.com/questions/28681719/scrolling-programmatically-thorzscrollbox-firemonkey-xe6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!