0
添加值後,我用建在UI列一個DataGridView,datagridview的數據源是空的UI
我添加了嘗試將數據源轉換成數據表的按鈕。
datagridview綁定到bindingsource,綁定到新的datatable。
在ui上添加值並單擊按鈕後,我嘗試從數據源獲取數據表,但它保留爲空。
BindingSource b = new BindingSource();
b.DataSource = new DataTable();
grdView.DataSource = b;
public void OnButtonClick()
{
BindingSource b = (BindingSource)grdView.DataSource;
DataTable dt = b.DataSource;
// dt keeps be null (but count is the count of the added rows)
}
是否要將其綁定到dataSource的副本或DataSource本身? –