Implement an instance of using the CheckBox column in the DataGridView control

  • 2020-11-03 22:06:25
  • OfStack


/// <summary>
        ///  implementation DataGridView In the control CheckBox The use of the column 
        /// </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;
                }
            }

Related articles: