Hi,
I try to select all cells of a column by code/program like a multi-select would do.
My code looks like this:
public void SelectColumn(int index) { foreach (UltraGridRow gridRow in _Grid.Rows) { if ((gridRow != null) && (gridRow.Cells.Count > index)) { gridRow.Cells[index].Selected = true; } } }
It works fine with about 1.000 rows, but with e.g. 10.000 rows, the performance is poor.Using Infragistics.Win.UltraWinGrid 11.1
Hello Stegerwald,
We are still following this thread.
Please feel free to let us know if the suggested approach works for you.
You could make this code more efficient in a couple of ways. For one thing, you don't need to check for gridRow != null - the Rows collection iterator should never return null.
Also, you are checking the cells count in each row, but you could really do this check once rather than on every iteration of the loop.
Lastly, instead of selecting each cell individually, you could use grid.Selected.Cells.AddRange.
if (index < this.ultraGrid1.DisplayLayout.Bands[0].Columns.Count) { List<UltraGridCell> cells = new List<UltraGridCell>(this.ultraGrid1.Rows.Count); foreach (UltraGridRow gridRow in this.ultraGrid1.Rows) { cells.Add(gridRow.Cells[index]); } this.ultraGrid1.Selected.Cells.AddRange(cells.ToArray()); }