Xceed Grid for WinForms v4.3 Documentation
Welcome to Xceed Grid for WinForms v4.3 / Task-Based Help / Rows / How to select a row(s) in code

In This Topic
    How to select a row(s) in code
    In This Topic

    To select one or more rows in code, you can add (or remove) rows from grid's SelectedRows property. Any row can be selected and added to the grid's collection of SelectedRows as long as its CanBeSelected property is set to true. 

    Keep in mind that the current row is not the same thing as the selected row and that the current row might not be part of the grid's selected rows. To learn how to change the current row, jump to the How to change the current row topic.

    Demonstration

    The following example demonstrates how to select a row via code.

    VB.NET Copy Code

    GridControl1.SelectedRows.Add( GridControl1.DataRows( 0 ) ) 

    Dim row As New TextRow( "This is my text row" ) 

    row.CanBeSelected = True 

    GridControl1.FixedFooterRows.Add( row )
    GridControl1.SelectedRows.Add( row )

    C# Copy Code

    gridControl1.SelectedRows.Add( gridControl1.DataRows[ 0 ] ); 

    TextRow row = new TextRow( "This is my text row" ); 

    row.CanBeSelected = true; 

    gridControl1.FixedFooterRows.Add( row );
    gridControl1.SelectedRows.Add( row );