I am attempting to copy datagridview rows to another datagridview when checkboxcolumn is checked. I am loading datagridview1 from treeview when child node is selected. However, when I select another childnode, the previous checkedbox disappears
private void BtnAdd_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Product Name");
dt.Columns.Add("Qty");
dt.Columns.Add("Unit Price");
foreach (DataGridViewRow row in dgvSelect1.Rows)
{
bool isSelected = Convert.ToBoolean(row.Cells["checkBoxColumn"].Value);
if (isSelected)
{
dt.Rows.Add(row.Cells[2].Value);
}
dgvSelect2.DataSource = dt;