我在我的应用中使用System.ComponentModel.BindingList
作为DataGridView.DataSource
。该列表非常大,需要几秒钟才能在DataGridView
上绘制。所以,我需要知道数据绑定(包含绘画)过程何时完成一些事情。我尝试了DataBindingComplete
事件,但是在将值设置为DataSource
属性后立即发生。
提前致谢。
的更新: 的
1. :生成绑定列表 [从数据库中获取数据] ►~1秒
2. 将其设置为DataSource
[绑定] ►~1秒({{1}现在就被提出来了。)
3。绘画 [显示DataBindingComplete
] 中的数据►~5秒
答案 0 :(得分: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..
}
}