I have inherited from Panel fir a custom control. I draw the
document
which is a bunch of hand drawn items. I set the
AutoScrollMinSize
property to control the scroll that the user sees. When the
user clicks
on an item that is only partly in view I scroll so the item
aligns with
the top or bottom of the view port.
here's a code snippet for items with the top above the view
port
//Point itemLocation
if (itemLocation.Top < 0)
{
int val = VerticalScroll.Value + itemLocation.Top;
// HACK: Alert calling "VerticalScroll.Value"
once doesn NOT work
// calling it twice does
VerticalScroll.Value = val;
VerticalScroll.Value = val;
AdjustFormScrollbars(true);
Invalidate();
}
I can't imagine that calling VerticalScroll.Value is
correct.
Any ideas?
adam
|