tora111
asked on
Clear datagridview
How can I clear a datagridview, delete all rows and columns ?
Thanks
Thanks
ASKER
bruintje, no both data and structure.
Because I created the structure at run-time by user-input, so I need to re-create the grid if user change input.
Because I created the structure at run-time by user-input, so I need to re-create the grid if user change input.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Me.DataGridView1.Rows.Clea r() 'Delete all rows in the datagridview1
'or
Me.DataGridView1.Columns.C lear() 'Delelte all rows and columns in the datagridview1
'or
Me.DataGridView1.Columns.C
ASKER
Thanks bruintje .
I know this is probably old but wouldn't just clearing the datasource be better?
DataGridView1.DataSource = null;
DataGridView1.DataSource = null;
assuming you mean to erase the data not the structure you can try
DataGridView1.Rows.Clear()
hope this helps a bit
bruintje