Panel control resets its scroll position

P

Paul E Collins

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.
 
C

Chris Jobson

Paul E Collins said:
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.

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top