Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
when I want to show a dataGridView with backgroundWorker I call showDGV("mydataGridViewname") in bw_dowork function .
C#
delegate void Dstr(string s);
public void showDGV(string s)
     {
         if (Controls[s].InvokeRequired)
         {
             Dstr h = new Dstr(showDGV);
             this.Invoke(h, new object[] { s });
         }
         else
         {
             Controls[s].Show();
         }
     }


now i want to do this dataGridView1.Rows.Clear(); with backgroundWorker.
I tried this:

C#
delegate void Dstr(string s);
public void DGVRowsClear(string s)
       {
           if (Controls[s].InvokeRequired)
           {
               Dstr h = new Dstrstr(DGVRowsClear);
               this.Invoke(h, new object[] { s });
           }
           else
           {
               Controls[s].Rows.Clear();//there is problem
           }
       }
Posted
Updated 15-Aug-14 15:45pm
v2
Comments
[no name] 15-Aug-14 21:54pm    
http://msdn.microsoft.com/en-us/library/ms171728.aspx
Subramanyam Shankar 7-Mar-15 11:38am    
What is the error you are getting?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900