To select all the rows in the UltraWinGrid programmatically, the obvious solution is to loop through all the rows and set the Selected Property of each row to true. However, this is inefficient and if there are a lot of rows in the grid, it can take more time than necessary.
A more efficient way to select all of the rows is to use the AddRange method.
The method listed above will select all of the root-level rows in the grid. This includes rows that are hidden or filtered out. It also means that if the root level is grouped, the GroupBy rows will be selected instead of the data rows.
If you want to select only data rows, you can use the following:
this.ultraGrid1.Selected.Rows.AddRange( this.ultraGrid1.Rows.GetAllNonGroupByRows() );
Me.UltraGrid1.Selected.Rows.AddRange( Me.UltraGrid1.Rows.GetAllNonGroupByRows() )
If you want to select only data rows that are not filtered out, use this code:
this.ultraGrid1.Selected.Rows.AddRange( this.ultraGrid1.Rows.GetFilteredInNonGroupByRows() );
Me.UltraGrid1.Selected.Rows.AddRange( Me.UltraGrid1.Rows.GetFilteredInNonGroupByRows() )
Note: UltraWinGrid does not allow selection across bands. The code listed here demonstrates selecting the rows in the root band only. You cannot select rows from different bands at the same time.