Hello,
Is there way to obtain a UltraGridRow from a DataRow? Please advise.
Adrian
Hi Adrian,
If you know the index of the row you can use the GetRowWithListIndex method on the Rows collection.
Otherwise, you will need to loop through the rows in the grid and examine the ListObject property of the row and compare it to the object you are looking for. If you are using a DataSet, keep in mind that the ListObject will return a DataRowView, not a DataRow - so be sure to get the Row propety from the DataRowView before you try to compare.
Question 1: In my case, the grid is bound to the DataView defined on a DataTable. At any point of time, one may see a subset of all records on the grid depending on the filter clause on the DataView. If the GridRow is not visible at the time of doing the GetRowWithListIndex, what would it return me?
In other words, does the GetRowWithListIndex work only if the GridRow is visible to the user?
Question 2:In response to a previous email from Adrian where he used this construct
UltraGridRow gridRow = UltraGrid1.DisplayLayout.Rows.GetRowWithListIndex(table.Rows.IndexOf(DataRow));
you wrote
Mike Saltzman"] That's good. But it's a bit inefficient, because you are now doing two linear walks instead of one. Once walk through the data rows with the call to IndexOf, and a second one through the grid's Rows collection for GetRowWithListIndex.
I see why this is not as efficient as your original suggestion. But when I tried to do it differently but I could not find any way to go from the DataRow to its index. I thought there would be a Index property on the DataRow that I could use. Any suggestions?
Thanks!
Thanks Mike! That seems to have worked. I found that it could also been done as shown below as well.
UltraGridRow gridRow =
UltraGrid1.DisplayLayout.Rows.GetRowWithListIndex(table.Rows.IndexOf(DataRow));