日期:2014-05-18  浏览次数:20898 次

datagridview 隐藏行
datagridview 隐藏行,选中一行不能隐藏,选中2行以上才可以,这是怎么回事啊
C# code

 private void lblAddDevice_Click(object sender, EventArgs e)
        {
            
            
            for (int i = 0; i < dgvDevice.Rows.Count;i++ )
            {
                DataGridViewCheckBoxCell chkCell = (DataGridViewCheckBoxCell)dgvDevice.Rows[i].Cells["Check"];
                Boolean flag = Convert.ToBoolean(chkCell.Value);
                if (flag)
                {
                    CurrencyManager cm = (CurrencyManager)BindingContext[this.dgvDevice.DataSource];
                    cm.SuspendBinding();
                   dgvDevice.Rows[i].Visible = false;
                   cm.ResumeBinding();
                   //disAbleCheck(i);
                   
               }
            }
}



------解决方案--------------------
C# code
bool flag = Convert.ToBoolean(chkCell.EditedFormattedValue);

------解决方案--------------------
C# code
   for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {

                DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)dataGridView1.Rows[i].Cells["Check"];
                if ((Boolean)chk.EditedFormattedValue == true)
                {
}
}