How to clear a DataGridView (Ranorex.Table)

Ask general questions here.
Posts: 39
Joined: Mon Jul 25, 2011 6:12 pm

How to clear a DataGridView (Ranorex.Table)

Post by LPG » Tue Sep 20, 2011 11:07 pm

How would I clear a DataGridView from all its contents? I've tried a Clear() on the rows, but this doesn't do anything at all. This is my code:

Ranorex.Table myTable = repo.Form.TestGrid;


User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA

Re: How to clear a DataGridView (Ranorex.Table)

Post by Support Team » Wed Sep 21, 2011 10:37 am


This is because "Clear()" clears/deletes the "IList" which you get if you call the "Rows" property.
Therefore you have to find a workaround to perform such a functionality.
Maybe you can iterate through your rows/cells and call some kind of a select and then delete each entry, but this depends on the structure and functionality of your Table.
Or you can try to iterate through your cells, call the "focus" method and perform a "Ctrl + A" and then "Delete" key event to delete each cell text.

Ranorex Support Team