Windows フォーム アプリケーションに DataGridView コントロールがあります。私がやりたいことはこれです:ビューをリロードして、バインドされているデータベーステーブルに変更が発生したときに正しいデータが表示されるようにします。つまり、DataGridView1.Rows.Remove(DataGridView1.CurrentRow) プロパティではなく SQL クエリを使用してレコードを削除すると、データグリッドビューにも変更が加えられます。例: datagridview にバインドされた顧客テーブルがあります。レコードを削除すると、たとえば ID=5 のレコードが実行時にグリッドビューから削除されます。これは可能ですか?
編集:
データソースを再バインドするために、顧客を削除するたびにこの手順を呼び出しています
Private Sub reloadDataset()
DataGridView1.DataSource = ""
DataGridView1.DataSource = CustomerBindingSource
End Sub
それはうまくいきません....何が間違っていますか?がんばってくれてありがとう..
編集2
明確にするために: CustomerBindingSource には DataSource(myDatasource) と datamember テーブル customers があります