PC Review


Reply
Thread Tools Rate Thread

How can I prevent a scrollbar to scroll when user selects a tab?

 
 
Pedro Rosas Silva
Guest
Posts: n/a
 
      19th Mar 2009
Hello,

I have a windows form with a TabControl "tabControl1" (with 2 tabs)
inside it.
Inside "tabControl1", I have another TabControl "tabControl2" (also with
2 tabs).

I have set the "AutoScroll" property of the form to true.

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.

Does anyone know how can I do it?
Thank you in advance.

Best Regards,
Pedro Rosas
 
Reply With Quote
 
 
 
 
Dawid Rutyna
Guest
Posts: n/a
 
      21st Mar 2009
(...)
> 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


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I make prevent the Validate event from going off when the user hits the Close button (the X button) or selects "Close" from the system menu? 0to60 Microsoft Dot NET Framework Forms 5 10th Sep 2008 10:46 AM
make scrollbar scroll up mcnews Microsoft Access Getting Started 11 6th Feb 2008 04:02 PM
shift-end in outline view selects *whole* paragraph -- prevent? =?Utf-8?B?d2lsbA==?= Microsoft Word Document Management 5 14th Oct 2007 04:00 AM
prevent mouse scroll to scroll in a dropdownlist nicholas Microsoft ASP .NET 0 7th Dec 2004 11:26 AM
Text de-selects when scroll bar is used (clicked on). =?Utf-8?B?aXJ2aW5nNzc3?= Windows XP General 2 22nd Jan 2004 10:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:29 AM.