C#设置自动滚动位置 [英] c# setting autoscrollposition
本文介绍了C#设置自动滚动位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我有一个用户控件,它是可滚动控件,并且我想更改其自动滚动位置(仅X值).
我正在这样做:
Hello,
I have a user control, which is scrollable control, and I want to change its autoscrollposition (only the X value).
I''m doing it like this:
int newScrollX = myFunction();
Point p = new Point(newScrollX, this.AutoScrollPosition.Y);
this.AutoScrollPosition = p;
newScrollX获取正确的值,p获取正确的点,但是在AutoScrollPosition设置行之后,AutoScrollPosition为(0,0).
有什么问题吗?
谢谢
newScrollX gets the correct value, p gets the correct point, but after the line of AutoScrollPosition setting, the AutoScrollPosition is (0,0).
What is the problem?
Thanks
推荐答案
它可能是无效值.您需要检查您的控制客户端大小,而不是System.Windows.Forms.ScrollableControl.AutoScrollMinSize
.另外,请确保您的System.Windows.Forms.ScrollableControl.AutoScroll
是真实的,并且将System.Windows.Forms.ScrollableControl.AutoScrollMargin
与System.Windows.Forms.ScrollableControl.AutoScrollOffset
一起考虑在内.您可能根本不了解这个概念,就像过去某些成员一样.
这是对问题的简单明了的文章:
http://www.bobpowell.net/understanding_autoscroll.htm [ http://msdn.microsoft.com/en-us/library/system. windows.forms.scrollablecontrol.aspx [ ^ ].
—SA
It might be invalid value. You need to check up your control client size, versusSystem.Windows.Forms.ScrollableControl.AutoScrollMinSize
. Also, make sure yourSystem.Windows.Forms.ScrollableControl.AutoScroll
is true and take into accountSystem.Windows.Forms.ScrollableControl.AutoScrollMargin
withSystem.Windows.Forms.ScrollableControl.AutoScrollOffset
. It''s possible that you simply did not understand the concept, as happens with some members in the past.
This is the article with minimalistic and clear explanation of matter:
http://www.bobpowell.net/understanding_autoscroll.htm[^].
See also:
http://msdn.microsoft.com/en-us/library/system.windows.forms.scrollablecontrol.aspx[^].
—SA
这篇关于C#设置自动滚动位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文