[英]Knowing when DataBinding is completed
我在我的應用程序中使用System.ComponentModel.BindingList
作為DataGridView.DataSource
。 該列表非常大,需要幾秒鍾才能繪制到DataGridView
上。 所以,我需要知道數據綁定(包括繪畫)程序何時完成才能做一些事情。 我嘗試了DataBindingComplete
事件,但它在為DataSource
屬性設置值后立即發生。
提前致謝。
更新:
1.生成綁定列表[從數據庫獲取數據] ► ~1 秒
2.將其設置為DataSource
[ Binding ] ► ~1 sec ( 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..
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.