ここで提起された問題と非常によく似た問題があります。シリアル ポートからのデータ ストリーミングがあります。シリアル受信イベントは、データ テーブル (同じクラスのパブリック プロパティ) を更新します。ポートでデータを受信したら、dataGridView のバインドを解除します。行を追加してデータ テーブルを更新します。次に、デリゲートを使用して dataGridView を更新します。デバッグ中 (または VS2010 内でリリースを作成中) はすべて正常に動作します。ただし、作成ディレクトリ (デバッグまたはリリース) またはインストールからプログラムを実行すると、dataGridView がスクロールを必要とする行数に達すると、プログラムがロックされてタイムアウトになりますか? VS2010内から実行している場合は発生しませんが、開発環境の「外部」では発生しますか???
から発生したイベントを使用して dataGridView を更新しようとしていdataRowChanged
ます。
コードは次のとおりです。
void dtData_RowChanged(object sender, DataRowChangeEventArgs e)
{
SetGridView(dataGridView1);
}
そしてデリゲート:
delegate void SetGridViewCallBack(DataGridView dgv);
private void SetGridView(DataGridView dgv)
{
// InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
if (this.dataGridView1.InvokeRequired)
{
SetGridViewCallBack d = new SetGridViewCallBack(SetGridView);
this.Invoke(d, new object[] { dgv });
}
else
{
this.dataGridView1.DataSource = dtData;
this.dataGridView1.ScrollBars = ScrollBars.None;
this.dataGridView1.Refresh();
this.dataGridView1.ScrollBars = ScrollBars.Vertical;
this.dataGridView1.Refresh();
// if scolled, focus on the last row
if (dataGridView1.Rows.Count > 3)
{
this.dataGridView1.CurrentCell = dataGridView1[0, dataGridView1.Rows.Count - 1];
}
}
OK - それで、なぜこれはIDEの「外側」でクラッシュするのでしょうか??? そしてb)私は何を間違っていますか???
助けてくれてありがとう