现象:
在DataGridView控件中的数据增加到超过其本身长度,出现控制条的时候。程序出现卡死现象。
解决方法:
在增加的函数中添加
dataGridView_Transefer.Invoke((MethodInvoker)delegate ()
{
});
例:
public void UpdateData(string DataDirection)
{
dataGridView_Transefer.Invoke((MethodInvoker)delegate ()
{
int Len = PassData.AnalysisData.Replace(" ", "").Length / 2;
string strPassdata = PassData.AnalysisData;
DataGridViewRow row = new DataGridViewRow();
DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
textboxcell.Value = DataDirection;
row.Cells.Add(textboxcell);
DataGridViewTextBoxCell textboxcel2 = new DataGridViewTextBoxCell();
DataGridViewTextBoxCell textboxcel3 = new DataGridViewTextBoxCell();
textboxcel2.Value = strPassdata;
row.Cells.Add(textboxcel2);
textboxcel3.Value = Len;
row.Cells.Add(textboxcel3);
dataGridView_Transefer.Rows.Add(row);
});
}