Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C#
int newScrollX = myFunction();
Point p = new Point(newScrollX, this.AutoScrollPosition.Y);
this.AutoScrollPosition = p;


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
Posted

1 solution

It might be invalid value. You need to check up your control client size, versus System.Windows.Forms.ScrollableControl.AutoScrollMinSize. Also, make sure your System.Windows.Forms.ScrollableControl.AutoScroll is true and take into account System.Windows.Forms.ScrollableControl.AutoScrollMargin with System.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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900