【发布时间】:2015-06-25 06:37:39
【问题描述】:
我正在尝试在添加多个记录后刷新 datagridview,这些记录是使用 bindingsource 和 datasource 以编程方式添加的。我的代码:
Private Async Function RefreshData() As Task
Await Task.Delay(15000)
bs.EndEdit()
daProducts.Update(dtProducts)
DataGridView1.DataSource = Nothing
DataGridView1.DataSource = bs 'Insert your DataSource here
bs.ResetBindings(False)
...
当我在表单加载事件中调用此函数时,它无法显示任何记录。
另一件事是,如果我不使用异步函数(因为设置 DefaultCellStyle.Alignment)会出错。
我的表单加载事件:http://sudrap.org/paste/text/554747/
【问题讨论】:
-
所以调用 RefreshData 后你的 DataGridView 是空的?
-
是的,调用函数后DataGridView1为空
-
但是你在
Form_Load中调用它...所以如果你不调用 RefreshData dataGridView1 不为空? -
不,如果我不调用该函数,它就不是空的。感谢您的帮助。
标签: vb.net visual-studio-2013 datagridview