We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

currentcell.moveto and scrollinview

We use the .moveto and scrollinview in our app all over the place. We finally used it on a form the other day where we wished the moveto and scrollinview would not only bring it in view but also make the currentcell''s row be the first row in the grid, or at least as high as it could go depending on where you were in your grid. say your current cell was on row 50 out of 100 and when you do the scroll it puts row 50 at the bottom of the grids displayed area. is there anyway you can make row 50 scroll in view at the top of that area when you can?

3 Replies

AD Administrator Syncfusion Team February 24, 2005 05:34 PM UTC

If you want the top row to be some particular rowindex, then set grid.TopRowIndex = someParticularRowIndex; This will force the display to be scrolled so the specified row is at the top.

PB Philip Bishop March 14, 2005 04:06 PM UTC

Clay, This works great but i was trying to add one functionality to it. If i scroll the bottom row to the top then i show the huge gap at the bottom of the grid that is empty. Is there a way i can say only scroll to the top as long as its not going to result in a huge dead space at the bottom? I thougth if i always show 10 rows on a screen then calculate it from the one i wan to bring to the top and if its a certain number dont bring it to the top. The only problem with that is if someone changes the screen resolution higher then what we develop in and test at that it can show more rows on screen at a time.

AD Administrator Syncfusion Team March 14, 2005 05:08 PM UTC

This will take a little coding on your part. You can use grid.RowHeights.GetTotal to compute the sum of the row heights from a ''potential'' TopRowIndex the grid.RowCount row. If this exceeds grid.ClientSize.Height minus the height of any frozen rows, then you can actually set this ''potential'' toprowindex to be teh TopRowIndex. If it does not exceed the client height, then instead of setting this potential index as the toprowindex, use ScrollCellInView to move that row into view (but not up to the top.) Or, you could calculate the exact TopRowIndex to set so most of the client area is occupied by the grid. To calculate the exact TopRowIndex, you can repeatedly call grid.RowHeights.GetTotal with a variable first row and always using grid.RowCOunt as the last row. Continue decrementingthe first row in teh loop until GetTotal exceeds the client height.

Live Chat Icon For mobile
Up arrow icon