Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1475
Programatically Re-Select the Row and Scroll Automatically
posted

Hi All,

I have a win grid with a max of 5000 rows at any given point of time. So the user will select a row on the grid and hit on the tool bar which invokes a winform. when the user x out of the form, the grid will be refresh automatically by getting a datasource from sql. But after the refresh I want the same row to be highlighted/selected and if the row # is say 4999, i want the scroll bar to navigate to that row automatically, so that the row is right now visible. Can we achieve this? This makes the user's life easy.

And by the way the grid has a column which is like primary key.

Thanks in advance.

Swetha.

Parents
  • 469350
    Offline posted

    Hi Swetha,

    Once you set the grid's DataSource, any existing rows in the grid are destroyed and a whole new set of rows are created for the new data. So you cannot store the row and re-select it.

    What you would have to do is store some information from that row like a primary key value. Then you would have to loop through the grid rows to find the row you want and make it the ActiveRow.

Reply Children