An incomprehensible situation occurred when deleting data from their dataGridView
if (dataGridView4.Rows.Count > 0) { this.Invoke(new Action(() => dataGridView4.Rows.Clear())); } for (int i = 0; i < Count; i++) { this.Invoke(new Action(() => dataGridView4.Rows.Add())); this.Invoke(new Action(() => dataGridView4.Rows[0].Visible = false)); this.Invoke(new Action(() => dataGridView4.Rows[i].Cells[0].Value = imageList2.Images[39])); } when you try to add them again displays a message on
this.Invoke(new Action(() => dataGridView4.Rows.Add())); Object reference not set to an instance of the object.
and if you do so
this.Invoke(new Action(() => listBox1.Items.Clear())); if (dataGridView4.Rows.Count > 0) { for (int i = 1; i < dataGridView4.Rows.Count; i++) { this.Invoke(new Action(() => dataGridView4.Rows.RemoveAt(i))); } //this.Invoke(new Action(() => dataGridView4.Rows.Clear())); } for (int i = 0; i < Count; i++) { this.Invoke(new Action(() => dataGridView4.Rows.Add())); this.Invoke(new Action(() => dataGridView4.Rows[0].Visible = false)); this.Invoke(new Action(() => dataGridView4.Rows[i].Cells[0].Value = imageList2.Images[39])); } then it only deletes part of the data.