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 Reply
  • 3707
    posted in reply to Swe2

    String primary_key = "suroor0@adventure-works.com";
    FilterCondition filter = new FilterCondition(FilterComparisionOperator.Equals, primary_key);
    ultraGrid1.Rows.ColumnFilters["EmailAddress"].FilterConditions.Add(filter);

    UltraGridRow our_row = ultraGrid1.Rows.GetFilteredInNonGroupByRows()[0];
    ultraGrid1.Rows.ColumnFilters.ClearAllFilters();
    ultraGrid1.ActiveRow = our_row;

    Place the primary key value into a variable when the user clicks that button on the toolbar to invoke the dialog you've created. When that gets closed, use the code above as your reference to get that row selected again.

    It's a little hack, but something different than looping like Mike always suggests (possibly faster??).

Children