AutoScroll question

W

WineNCheese

Hello all,

I have what I would think would be a relatively common problem, but I don't
see an obvious solution to it.

Situation:
o I have a UserControl that contains a data grid (I believe this will
happen with any control), that can be bigger than the client area of the
window.
o The UserControl has AutoScroll set to true, so there are scrollbars if
needed.

Problem:
If the UserControl is scrolled to a position such that the grid is partially
scrolled off the window, when the control gets focus, the UserGrid is
automatically scrolled so that the upper left of the grid is in the top left
of the window.

This is seemingly because of the following (taken from the help text for
AutoScroll):

If this property is set to true, scroll bars are displayed on the form if
any controls are located outside the form's client region. ***Additionally,
when autoscrolling is on, the client area of the form automatically scrolls
to make the control with input focus visible.***

How can I prevent this?

In my specific case, the user scrolls the control down to find a checkbox to
check in the grid, and when they check it, the control scrolls before the
mouse event takes place and the wrong cell is checked. So not only is the
control scrolling unexpectedly for the user, but the wrong data is changed
as well. Is there a way to turn off the movement of the control upon
receiving focus? or do I have to implement scrolling functionality myself?

Any suggestions would be greatly appreciated...

Thanx!
 
W

WineNCheese

Never Mind. I set the Selectable ControlStyle for the DataGrid to false and
all seemingly works fine.
 
W

WineNCheese

After using this for a while, it seems this fix has some small side effects,
which I guess I should have predicted related to keyboard navigation through
the control. I sincerely hope Microsoft removes this "feature" from
AutoScroll for the next release, and leaves it up to the programmer to
ensure visibility. Or at least make it an optional feature.

WNC
 
P

PaddyFrenchman

Can you give us the snippet of code that does it?
I have the same issue...

thanks a million.
 

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