Replies
Not really. The issues is that sometimes I am passing a RowsCollection, and in other instances it may be the IEnumerable. While I could certainly modify the receiving method to accommodate both, to me, it would just make more sense to be able to always pass a RowsCollection; i.e. – to take whatever form the rows are in and convert them to a RowsCollection. I'd really like to see this as a feature.
Thanks,
-Jayson
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
}
}
}
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?
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.
}
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?