This project is read-only.

Set First and Last VisibleScrollableColumn

Aug 29, 2009 at 6:16 PM

Hi,

Does anyone knows why can I redraw a grid, and after the redraw to set the previous values for First and LastVisibleScrollableColumn ?

Now I draw (initially) the grid with 30 columns, then scroll it to the most right column (in order to see it's content), and after the automatic redraw of the grid which is done by my app, the scroll bar is returned in the beginning of the grid ....  i.e. I see again the first columns, not the last.

I saw the First and LastVisibleScrollableColumn properties, but unfortunatelly they are read-only (i.e. I cannot set the stored values before the re-draw).

 

any clues?

Peter

 

Aug 29, 2009 at 8:12 PM
I can give you the 100% answer when I am at work on monday, but there is a scroll to function, and just call that. for example, I used a calendar, and if I to to have show the 30th day of a 3 month window, I just SetVScrollPos = 30.
 
I do not know the exact function ,but it is something that straight forward. Let me know if you need more help monday.
Derek
Aug 29, 2009 at 9:47 PM

I believe you are speaking about ScrollOnPoint (myScrollPosition) - thank you.

And one stupid question - how you get the right-most position which should be passed as parameter to ScrollOnPoint  ?

10x

Peter

Aug 29, 2009 at 10:58 PM
Yep! good one. You said that you already new the positions before the redraw... so just check what the vscrollpos is, redraw your grid, then set the scroll pos to what it was before.
 
Cheers!
Derek
Aug 30, 2009 at 9:16 AM
Edited Aug 30, 2009 at 9:24 AM

Yes, I capture the HScrollPositionChanged event, and I try to save the position of the scroll bar with sth like this:

myPoint = grid.HScrollBar.PointToClient(new Point(e.NewValue));  - But it seems I cannot save correctly the scroll bar position.

Do you know how to get the scroll bar position in Point object? I don't see any of the ScrollPositionChangedEventArgs holding the new value (e.NewValue returns -1, and is int, not Point). 

10x.

Peter

 

Aug 30, 2009 at 12:22 PM
the scroll pos is not in pixels, it is in cells.  Do not do a pointtoclient ...
 
Derek
Aug 31, 2009 at 7:22 AM

So, I found a solution! It is very simple indeed - just store and then set the Value property of the hscroll bar ! And that's it.

 

10x

Peter