Removing data from the grid is a simple process. Row.Remove() method deletes a row from the grid with all of its children. Call Grid.Rows.Clear() method to remove all rows from the grid. For better performance, when you delete many rows, you should disable sorting and remove data starting from the end of the grid.

C# Copy imageCopy
public void RemoveData(Grid grid)
    Product product1 = new Product();
    Product product2 = new Product();
    Product product3 = new Product();

    //Add data objects on the top hierarchical level. 
    Row row1 = grid.Rows.Add(product1);
    Row row2 = grid.Rows.Add(product2);

    //Add a data objects as a child of row2. 
    Row row3 = row2.Add(product3);

    //Removes the row1 from the grid

    //Removes all rows (visible and invisible from the grid)

Back to .Net Grid HowTo topics