Is it possible to convert a SelectedRowsCollection to a RowsCollection?
SelectedRowsCollection rows = ultraGrid1.SelectedRows;
RowsCollection rc = (RowsCollection)rows;
Hi Jayson,You can use the GetRowEnumertor method to loop through the entire WinGrid or all rows in a particular band or rows collection.It is not possible to convert SelectedRowsCollection to a RowsCollection.
Thanks,Josheela
Do you have a few lines of code to demo this?
Here's what I tried:
UltraGridBand band = ultraGrid1.DisplayLayout.Bands[1];
IEnumerator allRowsEnumerator = (RowsCollection)ultraGrid1.Rows.GetRowEnumerator(GridRowType.DataRow, band, null);
How can I then convert the allRowsEnumerator (either through a loop, or with some type of direct conversion) to a RowsCollection?
Josheela,
Thank you for the link:http://www.infragistics.com/help/winforms/wingrid-looping-through-the-entire-grid
I'd like to use the Enumerator to build a RowsCollection to pass to another method.
UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[1]; foreach (UltraGridRow row in band.GetRowEnumerator(GridRowType.DataRow)) { // Write code to process the row
// Here is where I'd like to build a collection of rows (RowsCollection) to pass to another method.
}
Hi Jayson,
GetRowEnumerator method gets all the rows associated with Bands[1].As you see in the below screenshot I have selected all rows in the Bands[1].
I would like to build a Collection of Rows, something like the following:
GridRowType rowTypes = GridRowType.DataRow;UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[1];IEnumerable enumerator = band.GetRowEnumerator(rowTypes);
RowsCollection rowsCollection = new RowsCollection();foreach (UltraGridRow row in enumerator){ rowsCollection.Add(row);}Is this possible?
As you can see, GetRowEnumerator returns a RowsCollection of GridRowType. But at this point we don't have a direct way of converting it to a RowsCollection.
It would be great if you can provide me a sample of your own so that I will have a clear understanding of your requirement and can assist you better.
Looking forward to hearing you back.
Again, I'd like to pass a RowsCollection to another method to perform some operations on Rows in the UltraGrid. I'd like to be able to pass only the Rows that I need, so that I don't have to perform the operation on all Rows.
Example:
private void GetRows(){ GridRowType rowTypes = GridRowType.DataRow; UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[1]; IEnumerable enumerator = band.GetRowEnumerator(rowTypes); RowsCollection rowsCollection = new RowsCollection(); //Either build RowsCollection via Loop foreach (UltraGridRow row in enumerator) { rowsCollection.Add(row); } //Or, cast IEnumerable to RowsCollection rowsCollection = (RowsCollection)enumerator;}
private void UpdateRows(RowsCollection rows = null){ if (rows != null) { foreach (UltraGridRow r in rows) { //Perform operation on SPECIFIED rows here } } else { rows = ultraGrid1.Rows; foreach (UltraGridRow r in rows) { //Perform operation on ALL UltraGrid rows here } }}
Is it possible for you to change the method to use IEnumerable as argument instead of rows Collection so that you can pass the enumerator which itself is the RowsCollection.