Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Remove check box column from datagridview when clear datagridview using c#

$
0
0

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???



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>