dataGridView DataGridViewCheckBoxColumn 列的选择与反选择


 注意设置 DataGridViewCheckBoxColumn 列的TrueValue 和 FalseValue 值分别为  true,false

    private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        

          
            
if (e.RowIndex!=-1)
            
{
                
bool t = false;
                
if (this.dataGridView1.Rows[e.RowIndex].Cells[0].Value != null)
                
{
                    t 
= this.dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString()=="true"?true:false;
                     t 
= !t;
                    
this.dataGridView1.Rows[e.RowIndex].Cells[0].Value = t;
                }

           }

        }

posted on 2008-03-20 11:25  gwazy  阅读(2627)  评论(0编辑  收藏  举报

导航