How to clear a DataGridView (Ranorex.Table) : General Questions

How to clear a DataGridView (Ranorex.Table)

Ask general questions here.

How to clear a DataGridView (Ranorex.Table)

Postby LPG » Wed Sep 21, 2011 12:07 am

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;
myTable.Rows.Clear();

Thanks!
LPG
 
Posts: 25
Joined: Mon Jul 25, 2011 7:12 pm

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

Postby Support Team » Wed Sep 21, 2011 11:37 am

Hi,

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.

Regards,
Markus
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to General Questions

Who is online

Users browsing this forum: No registered users and 1 guest