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
1170
Programmatically selecting/activating a row?
posted

I have a readonly UltraGrid that is bound to a datasource that contains an ID column as the PK for the collection. I would like to select a specific row based upon the ID and highlight/activate it programmatically. The grid should scroll to the proper location if the selected row is not visible.

QUESTION: Is there an example of how I can do this?

Parents
  • 69832
    Suggested Answer
    Offline posted

    The grid follows the current record of the data source to which it is bound by default, meaning you would just have to set the binding manager's Position property to the index of the record that you want to "select":

    UltraGrid grid = this.ultraGrid;
    BindingManagerBase bm = grid.BindingContext[grid.DataSource, grid.DataMember];
    bm.Position = 0;

    Note that you can also select and activate an UltraGridRow programmatically; set the UltraGrid.ActiveRow property to activate the row, and use the Rows property of the Selected object to select a row:

    this.ultraGrid.ActiveRow = row;
    this.ultraGrid.Selected.Rows.Add( row );

Reply Children