当前位置:主页 > 软件编程 > .NET代码 >

实现DataGridView控件中CheckBox列的使用实例

时间:2021-04-06 10:01:52 | 栏目:.NET代码 | 点击:

复制代码 代码如下:

/// <summary>
        /// 实现DataGridView控件中CheckBox列的使用
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvTradList_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0 && e.RowIndex != -1)
            {
                if ((bool)dgvTradList.Rows[e.RowIndex].Cells[0].EditedFormattedValue == true)
                {
                    dgvTradList.Rows[e.RowIndex].Cells[0].Value = false;
                }
                else
                {
                    dgvTradList.Rows[e.RowIndex].Cells[0].Value = true;
                }
            }

您可能感兴趣的文章:

相关文章