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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to make CurrentRowIndex the Top row in datagrid.

Thread ID:

Created:

Updated:

Platform:

Replies:

390 Jun 19,2002 10:16 AM UTC Jun 22,2002 09:10 AM UTC WinForms 2
loading
Tags: FAQ
Maurits de Loë
Asked On June 19, 2002 10:16 AM UTC

Dear all, How do I make the CurrentRowIndex the Top row visible in a datagrid? Basically I need to scoll through my dataset by using buttons. (The next button gets the next 40 records from the db and appends them to the dataset. The first new row should be the top row in the dataset.) Hopefully I'm clear enough and "can be helped" ;-) Thanks

Clay Burch [Syncfusion]
Replied On June 20, 2002 08:09 AM UTC

There appears to be no TopRow property exposed in the DataGrid, and also no scroll command. The FAQ referenced below explains how you can write a method that returns the TopRow. This will not let you actually set the TopRow to some particular row though. But you can probably write a method that would do it based upon the idea that when you set a new CurrentCell, the DataGrid scrolls to make it visible. Here's how you could use this idea. Set the currentcell to the row you want to be the toprow. Then check the actual toprow index. If it is less, we need to make the datagrid scroll up. If it is higher, we need to make the datagrid scroll down. To actually do the scrolling once the direction is known, just incrementally set higher (or lower) current cells until the toprow is on the row you desire. You would also probably want to sandwich this code between BeginUpdate and EndUpdate/Invalidate calls so the positioning appears cleaner without seeing the individual scrolls drawn. Now I did not actually try this idea, so I am not sure what kinds of problems you might encounter. George Shepherd's Windows Forms FAQ contains an entry entitled: How do I find the top-left visible cell in a datagrid? Check it out at: http://www.syncfusion.com/faq/winforms/search/880.asp

Clay Burch [Syncfusion]
Replied On June 22, 2002 09:10 AM UTC

Here is a simple way to scroll the datagrid. It uses a protected member of the DataGrid, so you have to have a derived datagrid to use it. George Shepherd's Windows Forms FAQ contains an entry entitled: How do I programatically scroll the datagrid to a particular row? Check it out at: http://www.syncfusion.com/faq/winforms/search/895.asp

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;