Knowledge on DataBinding Completion

I used System.ComponentModel.BindingList

both DataGridView.DataSource

in my application. The list is quite long and takes a few seconds to draw on DataGridView

. So, I need to know when the data binding routine ends ( drawing enabled ) in order to do some things. I tried the event DataBindingComplete

, but it happens right after setting the value to the property DataSource

.

Thanks in advance.


UPDATE:

1. Creating a binding list [ Retrieving data from the database ] ► ~ 1 s

2. Setting DataSource

[ binding ] ► ~ 1 sec (now appears DataBindingComplete

.)

3. Painting [ Display data in DataGridView

] ► ~ 5 seconds

+3


source to share


1 answer


It was as easy as described!



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.. 
    }
}

      

+5


source







All Articles