I have 2 DataGridView controls on my search form. I have manually created the columns for the 1st grid, but now I want to dynamically duplicate those columns in the 2nd grid.
Using the code below, I get this error: "Provided column already belongs to the DataGridView control."
I'm not sure what the error is trying to tell me. The dgvSelected grid has 0 (zero) columns before this code is ran. "CustomerSearch" is a user-control that contains a DataGridView control called "dgvSearch".
Any ideas as to why I am getting this error?
tia,
flynn
Using the code below, I get this error: "Provided column already belongs to the DataGridView control."
Code:
Control[] ctl = CustomerSearch.Controls.Find("dgvSearch",false);
foreach (DataGridViewColumn dgvCol in ((DataGridView)ctl[0]).Columns)
{
dgvSelected.Columns.Add(dgvCol);
}
I'm not sure what the error is trying to tell me. The dgvSelected grid has 0 (zero) columns before this code is ran. "CustomerSearch" is a user-control that contains a DataGridView control called "dgvSearch".
Any ideas as to why I am getting this error?
tia,
flynn