0
フォームロード時にDataGridをバインドします。windowsアプリケーションを使用してendsitイベントでデータグリッドを更新する
DataGrid1.DataSource = objBindinglist
は、編集後、私はデータグリッドをリフレッシュしたい
DataGrid1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { DataGridViewCell cell = null; if (e.RowIndex > -1 && e.ColumnIndex > -1) { cell = ((DataGridView)sender).Rows[e.RowIndex].Cells[e.ColumnIndex]; ((DataGridView)sender).Rows[e.RowIndex].Cells[sates.Index].Value = cell; } }
データグリッドで値を変更しました。
private void DataGrid1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { ((DataGridView)sender).DataSource = null; var lstDataSource = ((BindingList<person>)(((DataGridView)sender).DataSource)) .OrderByDescending(x => x.sates).ToList(); objBindinglist = new BindingList<person>(lstDataSource); DataGrid1.DataSource = objBindinglist;
1つのバインディングリストが先頭に宣言されている。
BindingList<person> objBindinglist = new BindingList<person>();
質問: はそれが有界データグリッドにリフレッシュリストをバインドすることは可能です。 データソースがnullの場合、エラーが返されます。
終了編集イベントでエラーが発生します。 – user990897
@ user990897:何のエラーが出ますか? –
SetCurrentCellAddressCore関数へのリエントラントコールが発生するため、操作は無効です – user990897