Hi
I set contextmenuStrip for the ultraGrid.Click the button of the contextmenuStrip to select the ultraGrid all rows.The currnet UltraGrid has the least 5000 data.Then change the selected row in a column of data.Such as: this.UltraGrid.ActiveRow = null; this.UltraGridSelected.Rows.Clear(); for (int i = 0; i < this.UltraGrid.Rows.Count; i++) { this.UltraGrid.Rows[i].Selected = true; }(Or use the foreach,Bind)
if (this.UltraGrid.Selected.Rows.Count > 1) { for (int i = 0; i < this.UltraGridSelected.Rows.Count; i++) { this.UltraGrid.Selected.Rows[i].Cells["Cloumn6"].Value = strProType; } }
But this efficiency is very low,resulting in slow page.There is better way to solve this problem?
Note that this only works in a single band grid, but this code uses the ISelectionManager interface to range select rows, which applies the selection in one atomic operation rather than one for each row:
private void SelectAllRows( UltraGrid grid ){ UltraGridRow first = grid.Rows.Count > 0 ? grid.Rows[0] : null; UltraGridRow last = grid.Rows.Count > 0 ? grid.Rows[grid.Rows.Count - 1] : null;
if ( first != null && last != null ) { ISelectionManager selectionManager = grid as ISelectionManager; selectionManager.SetPivotItem( first, false ); selectionManager.SelectItem( first, false ); selectionManager.SelectRange( last, false ); }}
HOWTO:What is the best way to programmatically select all rows in the grid?
Thanks.
The efficeincy is raised to select the ultraGrid all rows.But update slow to selected Grid rows data.
Looping through the rows forces the grid to create UltraGridRow and UltraGridCell objects for every row. There's no way around that.
But if you are updating every row in the grid, why not simply loop through the rows in the data source, instead? That might be faster.
Hi Mike,
I am trying to select rows from a grid. The link to select rows programatically doesn't work for me since we are providing a invert selection functionality. This functionality requires looping through all records in ultragrid and inverting selection
ie. Grid.Rows[i].Selected = !(Grid.Rows[i].Selected)
This is memory and time consuming operation. Is there a better way to do this. Also you mentioned using the data source instead. I don't understand that. Can you please elaborate on that?
Thanks
Shankar