If you work with reference-type objects in grid rows, you can easily find grid row or rows that contain you objects. This functionality is available via Grid.DataObjects property. Please see an example of its use below.

C# Copy imageCopy
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
    }
}

Back to .Net Grid HowTo topics