(...)
> The problem is that when the scrollbars are showing up, if the user
> clicks one of the tabs, the scrollbar rolls down to it.
> I don't want this behaviour. I want the scrollbar to retain its position.
(...)
The problem is that you can't change this bahavior. The solution is to
update the scrollbar position after it's "auto update". Next problem is that
it is "auto updated" after events handlers so to overcome this we have to
send windows message. The solution:
public delegate void AutoScrollPositionDelegate(ScrollableControl ctrl,
Point p);
//Some control gain focus
private void Control_Enter(object sender, System.EventArgs e)
{
Point p = this.AutoScrollPosition;
AutoScrollPositionDelegate del = new
AutoScrollPositionDelegate(SetAutoScrollPosition);
Object[] args = { this, p };
BeginInvoke(del, args);
}
private void SetAutoScrollPosition(ScrollableControl ctrl, Point p)
{
p.X = Math.Abs(p.X);
p.Y = Math.Abs(p.Y);
ctrl.AutoScrollPosition = p;
}
Dawid Rutyna
|