假设 DataGridView
将其 DataSource
属性设置为 DataView
实例。
DataGridView dgv;
DataTable dt;
// ... dt gets populated.
DataView dv = dt.DefaultView;
dgv.DataSource = dv;
// ... dt gets modified
// The DataGridView needs to update to show these changes visually
// What goes here?
我知道您可以将 dgv.DataSource
设置为 null
,然后返回到 dv
。但这似乎很奇怪。我敢肯定还有其他几种方法。但正确的官方方法是什么?
最佳答案
正确的方法是数据源实现IBindingList
,为SupportsChangeNotification
返回true
,并且发出 ListChanged
事件。然而,据我所知,一个DataView
做这个...
关于c# - 让 DataGridView 直观地反射(reflect)其 DataSource 中的变化的正确方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/630343/