The CheckBox in DataGridView in C#
DataGridView provide checkbox control “DataGridViewCheckBoxColumn” for selecting particular row value. In this article,
I tell you how to use DataGridView’s checkbox control in your windows application. The steps are given below.
Step 1:Create one windows application and drag-drop DataGridView control.
Step 2: Rightclick on DataGridView and select the “Edit Column…” option.
Step 3:Click on the button “Add” and select the “DataGridViewCheckBoxColumn” option from type comboBox and give that name with header text as below image.
Step 6: After adding “DataGridViewChekBoxCOlumn”, your windows form look as below image.
Step 7:Now bind DataGridView from the database. Follow the below link for binding database table into DataGridView.
Step 8: Now check your application. My application screen shot as given below.
John Smith
01-May-2015Michelle Baluran
29-Apr-2015John Smith
02-Sep-2013kasireddy golamaru
02-Sep-2013Manmohan Jha
09-Jun-2013foreach (DataGridViewRow dgvR in dgvshow.Rows)
{
DataGridViewCheckBoxCell CbxCell = (DataGridViewCheckBoxCell)dgvR.Cells[0];
if (Convert.ToBoolean(CbxCell.Value) == true)
{
i++;
}
}
MessageBox.Show(i.Tostring());