I did this test, I need to reload the datagridview with data every 4 seconds, and the data came from the database.
therefore, i'v created a timer control by code and added an event handler to the event tick. Then in event ticks
void t1_Tick(object sender, EventArgs e)
{
dataGridView1.DataSource = null;
dataGridView1.Rows.Clear();
dt = Product.GetAllProductsBasicInfo();
dataGridView1.DataSource = dt;
}
above code works but when i move
dataGridView1.Rows.Clear();
before
dataGridView1.DataSource = null;
it will throw a runtime error saying that the rows cannot be cleared, I want to know why it throws this error, usually Clear () clears the datagridview?
thanks
source
share