i have created datagridview dynamically with check box column,once i refresh my datagrid its removes all data except checkbox column,below code for adding checkbox column in datagrid
DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();
dataGridView1.Columns.Add(chk);
chk.HeaderText = "Check Data";
chk.Name = "chk";
int count = dataGridView1.Rows.Count;
for (int i = 0; i < count; i++)
{
dataGridView1.Rows[i].Cells[12].Value = false;
}
and below code for clearing my datagrid,if i try to add new data in datagridview after refresh still old check box exists and it keeps adding one more checkbox column.
dataGridView1.Rows.Clear();
dataGridView1.Refresh();
any suggestion???
Loading
R JPosted Aug 27, 2014, 12:32 AM
Try this way
vikas kumarPosted Jul 2, 2017, 4:49 AM
dataGridView1.Controls.Remove(ckBox);
}
Archana PalaniPosted Aug 27, 2014, 2:29 AM
R JPosted Aug 27, 2014, 1:07 AM
If you can not obtain the same checkbox column object try remove the column using index value.
If this column is 5th column in datagrid then
datagrid.Columns.Remove(4)
Archana PalaniPosted Aug 27, 2014, 12:46 AM
its throwing the following error