Hello all,
Can the UltraGrid rows collection be cast to a DataRowCollection or some other list of DataRows or DataRowViews? Similarly, can the UltraGrid columns collection be cast to a DataColumnCollection or some other list of DataColumns? Thanks in advance for any ideas and/or suggestions!
If I understood you, each row datasource is a DataRow (or DataRowView).
grid.Rows.OfType<UltraGridRow>().Select(r => (DataRow)r.ListObject).ToArray()
Do you have a VB.Net equivalent? I haven't been able to find the OfType equivalent.
Hello,
Thanks again for all of your help. Your example worked when I changed the Select to DataRowView and the last cast to DataRowView instead of DataRow in both cases.
For Each rowView As DataRowView In Me.grdNav2.Rows.OfType(Of UltraGridRow).Select(Of DataRowView)(Function(row) DirectCast(row.ListObject, DataRowView)) ' Do something.Next
write:
Dim rows = (mycode)
You can iterate it with foreach or with any Linq method as any other array of DataRowView
Hello Amiram Korach,
Thank you very much for sticking with this thread. There are multiple projects in the solution I am testing and it turned out to be that the project containing my form was not Framework 3.5, it was 2.0. When I changed it to 3.5, your code worked.
Your very first example worked after I changed (DataRow)r.ListObject to (DataRowView)r.ListObject.
How would I iterate over the last example you posted?
Add "using System.Linq" at the top of the page. (or "Imports")
I copied your code and replaced UltraGrid1 with my form's UltraGrid variable name. Upon doing so, I get a compile error: 'OfType' is not a member of 'Infragistics.Win.UltraWinGrid.RowsCollection'. We are using 9.1.