0

I get a problem when adding columns to a dataGrid.
I keep adding columns with the code below.
It works well until the column will come outside the right side of the dataGrids Widh.
When it does, the program will get stuck for 2 minutes or so and the column was added.
I have both scrollbars on the dataGrid.

Anyone who can think of why this happen or have got the same problem before.

dataGridView1->Columns->Add(); //Add 1 more Column
1
Contributor
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Lukezzz
0

I have found out the exact difference of my problem. If I add columns to the dataGridView like this using a button, it will work.

for( int i = 0 ; i < 20; i++)
{
	 dataGridView1->Columns->Add("a", "b"); //Add 20 columns
}

But if I will let the backgroundworker do it like this, the whole application gets stuck completely and I must close the program with taskmanger.
I cant figure it out what the difference are. It is exactly the same code initially that is running ?
Could wonder if it is a bug.

backgroundWorker1->RunWorkerAsync(); //Start backgroundworker
private: System::Void backgroundWorker1_DoWork(System::Object^  sender, System::ComponentModel::DoWorkEventArgs^  e) 
{
      for( int i = 0 ; i < 20; i++)
     {
     	 dataGridView1->Columns->Add("a", "b"); //Add 20 columns
     }
}
backgroundWorker1->CancelAsync();
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.