此时全选,反选会出现bug
//全选

  private void label9_Click(object sender, EventArgs e)      

   {          

   if (Data_Grid.Rows.Count > 0)           

  {                 

Data_Grid.EndEdit();                

for (int i = 0; i < Data_Grid.Rows.Count; i++)                

{                    

Data_Grid.Rows[i].Cells[0].Value = true;                

}            

}        

}

//反选

 private void label19_Click(object sender, EventArgs e)        

{                      

if (Data_Grid.Rows.Count > 0)            

{                

Data_Grid.EndEdit();//解决选中某行时,全选,反选时,checkbox不能勾选,取消的问题                             

for (int i = 0; i < Data_Grid.Rows.Count; i++)                

{                    

Data_Grid.Rows[i].Cells[0].Value = !(bool)Data_Grid.Rows[i].Cells[0].EditedFormattedValue;                                  

}            

}        

}

posted on 2015-08-18 11:17  初夏0112  阅读(347)  评论(0)    收藏  举报