Reverse search by dataObjects
CompletedHi, It would be nice with a method like: grid.Rows.IndexOfDataObject(object o) I would like to find the row which contains a given DataObject". I have found no other way than to do:
foreach (Dapfor.Net.Ui.Row row in grid.Rows)
if (row.DataObject==xxx)
{
found=row;
break;
}
I could store a pointer to the Row object in each of my "DataObjects", but that would break the separation between data & UI.
0
-
Hi,
A small clarification: the same data object can be inserted several times into the .Net Grid. Thus the grid should return a collection of Rows as well as the first found Row.
Here is an example:
public void ReverseSearchExample(Grid grid)
{
//Add some products...
Product product1 = new Product();
Product product2 = new Product();
grid.Rows.Add(product1);
grid.Rows.Add(product2);
//The first found row (not the first visible - just the first found!)
Row row1 = grid.DataObjects.FindFirstRow(product1);
//Enumerate all rows, related to the data object
foreach (Row row in grid.DataObjects.Find(product1))
{
//Do something here
}
}0
Please sign in to leave a comment.
Comments
1 comment