Mim*_*imi 3 c# binding datagridview winforms
我已经在我的应用程序中使用了System.ComponentModel.BindingList
它DataGridView.DataSource
.该列表非常大,需要几秒钟才能绘制出来DataGridView
.所以,我需要知道数据绑定(包括绘画)程序什么时候完成一些东西.我尝试了DataBindingComplete
事件,但它在向DataSource
属性设置值后立即发生.
提前致谢.
更新:
1.生成绑定列表[从数据库获取数据] ►~1秒
2.将其设置为DataSource
[ Binding ] ►~1秒(此时DataBindingComplete
正在抬起.)
3.绘画[显示数据DataGridView
] ►~5秒
这就像描述一样简单!
bool bindingCompleted = false;
void Form1_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = bindingList1;
}
void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
bindingCompleted = true;
}
void dataGridView1_Paint(object sender, PaintEventArgs e)
{
if (bindingCompleted)
{
bindingCompleted = false;
// do some stuff..
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7449 次 |
最近记录: |