Groups | Blog | Home
all groups > c# > may 2006 >

c# : Panel control resets its scroll position


Paul E Collins
5/28/2006 10:09:38 PM
I'm writing an application whose main window consists of a particular
UserControl that I have placed inside a docked Panel so that it will
fill the whole window. The panel also has the AutoScroll property set
so that the user can scroll if the inner control is larger than the
window.

Various dialogue boxes (displayed with Form.ShowDialog(this)) are
available for setting properties, etc., and I've noticed that when a
dialogue box is closed, the panel immediately reverts back to its top
left-hand corner, forgetting where the user had scrolled.

I can probably work around this by saving and restoring the scroll
position, but is this a known bug or some feature of the Panel that
I'm overlooking? It's definitely not my code.

Eq.

Chris Jobson
5/28/2006 11:49:53 PM
[quoted text, click to view]

Not sure if it's the same problem, but I've noticed that if the user scrolls
a form/panel so that the active control is not fully visible then when the
form regains focus after losing it (whether because another form is shown,
or because the user switches away to another application), the form/panel
scrolls to make the active control visible. Unfortunately I can't find any
simple way to prevent this.

Chris Jobson

tony lock
5/29/2006 2:19:08 AM
I found exactly the same problem, if you save the scroll positions before
calling the dialog box. Then after the dialog is closed set the scroll
positions back to their original positions, you will stop the contents of the
panel moving, but the scroll bar(s) are to the left/top i.e. they do not
match the contents.

[quoted text, click to view]
AddThis Social Bookmark Button