0
votes

i am using the following to remove all list of gridControl but its not working giving error at Rows.no defination for Rows how can i loops throughs to remove all elements.

do
{     
    foreach (DataGridViewRow row in gridControl1.Rows)
    {
        try
        {
            gridViewForVariableLinkage.Rows.Remove(row);
        }
        catch (Exception) { }
    }
} while (gridViewForVariableLinkage.Rows.Count > 1);
1
gridControl1.ItemsSource=NULL , isn't an option? - apomene
not options like that - user3818875
what is the exception? - Ehsan Sajjad

1 Answers

1
votes

You can do it using for loop this way:

for (int i = 0; gridViewForVariableLinkage.RowCount > 1; i++)
{
   gridViewForVariableLinkage.DeleteRow(i);
}