winform中DataGridView使用DataGridViewCheckBoxColumn实现RadioBox单选功能

private void dgvMaterial_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            for (int i = 0; i < dgvMaterial.Rows.Count; i++)
            {
                DataGridViewCheckBoxCell ck = dgvMaterial.Rows[i].Cells[0] as DataGridViewCheckBoxCell;
                if (i != e.RowIndex)
                {
                    ck.Value = false;
                }
                else
                {
                    ck.Value = true;
                }
            }
        }

 

posted @ 2017-08-29 18:18  凉城旧巷旧少年  阅读(820)  评论(0编辑  收藏  举报