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
115
Clearing selected and/or active row...
posted

I have a grid which I am setting the datasource for, and after I do this I want it to have NO rows of the grid selected or active... so, I set the datasource:

SetDataBinding(dataSource, null, false);

and then I make the following calls in hopes that nothing is selected/active

ActiveRow = null;
Selected.Rows.Clear();

but this does not work (first row is always highlighted)... I assume this is simple, but for some reason everything I try does not work... also, do NOT want to achieve this by resetting or disabling the grids active/selected row appearances as I still want the user to be able to select something after the data source is set.

Thanks!

  • 469350
    Verified Answer
    Offline posted

    Hi,

    The reason the row gets activated (not selected) is that the grid automatically synchronizes it's ActiveRow with the current position of the BindingManager. this happens by default, but you can turn it off. Just set SyncWithCurrencyManager on the grid to false.

    The only potential down side to this is if you are relying on the grid and the data source being at the same position. So if you have other controls that are bound to the same data source as the grid, they won't automatically stay in synch any more. But that's probably not a problem.