Skip to content

Replies

0
Jayson Hinkel
Jayson Hinkel answered on Oct 31, 2016 2:59 PM

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 

0
Jayson Hinkel
Jayson Hinkel answered on Oct 28, 2016 6:06 PM

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
        }
    }
}

0
Jayson Hinkel
Jayson Hinkel answered on Oct 27, 2016 8:13 PM

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?

0
Jayson Hinkel
Jayson Hinkel answered on Oct 27, 2016 12:48 AM

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.
}

 

0
Jayson Hinkel
Jayson Hinkel answered on Oct 27, 2016 12:41 AM

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?