以编程方式滚动窗口移动窗口窗口、方式

2023-09-07 00:40:59 作者:采花大盗

我有上有许多控件(足以使滚动条可见)的形式。我如何可以通过编程控制滚动窗口?

I have a form that has a number of controls on it (enough that the scroll bar is visible). How can I programmatically control the scroll window?

我可以伪造它现在通过调用Form中的最后一个控件的。选择()的方法,但我真的希望能够滚动所有的方式向窗口的底部。

I can fake it now by calling the .Select() method on the last control in the Form, but I'd really like to be able to scroll all the way to the bottom of the window.

推荐答案

的形式所具有的AutoScrollPosition财产。您可以设置它像下面的例子:

The Form has an AutoScrollPosition property. You can set it like in the following example:

this.AutoScrollPosition = new Point(0, this.Height);

这将完全滚动的形式向底部。对于这个工作,虽然,你需要有Form.AutoScroll属性设置为True。将其设置为true,则表单显示滚动条。我不知道如何可以隐藏起来,但仍然得到使用AutoScrollPosition的好处。

This will scroll the form exactly to the bottom. For this to work though, you need to have the Form.AutoScroll property set to True. Setting this to True, makes the form show scroll bars. I am not sure how one could hide them but still get the benefit of using AutoScrollPosition.