views:

35

answers:

2

I am using C# + winforms to develop software.
I have a UserControl which contains several DataGridView

datagridview1.datasource = from p in dc.doctor select p;

I use linq to sql to populate the dataGridView with dataSource, because I need to refresh the datasource to update the records, so I create a new dataContext and assign the datasource again.

datagridview1.datasource = from p in dc.doctor select p;  

At first I found, although I reset the datasource, the datagridview still can not get refreshed, someone tell me that I should call the invalidate function on datagridview, I tried. To a certain extent, it works. But If I called the Invalidate inside the UserControl's class, it won't work.
If I create a public function on the UserControl's class, then call it with userControl.refreshRecord(), Then it works.

Can someone point me what am I missed ? When someone call invalidate, when will it really work?
Thanks in advance !

A: 

Call dgv.Invalidate() method for datagridview.

Rohit
Did you finish to read my question ? I called the invalidate function, but if I call it inside the control, it won't work. I have to call it outside the usercontrol, then it works.
MemoryLeak
wonderful correct answer is that it works and you are wrong. wow what a sick guy
Rohit
A: 

Invalidate work when the control finish all other things like data loading ...

MemoryLeak