If I want to select, then delete all of the rows in a grid, how do I do that in Visual C#?
Here is the code I have so far:
ultraGridExceptions.Selected.Rows.AddRange(ultraGridExceptions.Rows.All);
I am getting this error when trying to build:
Error 1 The best overloaded method match for 'Infragistics.Win.UltraWinGrid.SelectedRowsCollection.AddRange(Infragistics.Win.UltraWinGrid.UltraGridRow[])' has some invalid arguments
Hi,
you can try the following approach:
ultraGrid1.Selected.Rows.AddRange(ultraGrid1.Rows.ToArray<UltraGridRow >());
and then
ultraGrid1.DeleteSelectedRows();
I hope it is helpful. If you have any further questions, do not hesitate to ask.
Stefaniya
Developer Support Engineer
Infragistics, Inc
http://ko.infragistics.com/support
Try this:
this.ultraGrid1.Selected.Rows.AddRange((UltraGridRow[])this.ultraGrid1.Rows.All); this.ultraGrid1.DeleteSelectedRows(false);
The reason your original code didn't work is that the All property returns an object array, not an UltraGridRow array. So you just have to cast it.
BTW... I got the correct AddRange code from the Infragistics KB here: HOWTO:What is the best way to programmatically select all rows in the grid?
This portion of code doesn't work if you had set the property SelectTypeRow = None or Single, and when you want to select all the rows ((UltraGridRow[])this.ultraGrid1.Rows.All), the ultragrid component throws an exception.
Hi Cristian,
The simplest way around that would be to change the SelectTypeRow to Multi before this code, and then re-set it back to the original value after.