HI,
At the moment I'm facing a problem. I have a datagridview1 in FORM1 and datagridview2 in FORM2. I want to duplicate the data in datagridview1 to datqagridview2 in another form.
The code I used is:
FORM1:
OdbcCommand bcCom2 = new OdbcCommand();
bcCom2.CommandText = "" + content + "";
bcCom2.Connection = OdbcCon;
DataSet q2 = new DataSet();
OdbcDataAdapter dbA2 = new OdbcDataAdapter(bcCom2);
dbA2.Fill(q2);
dataGridView1.DataSource = q2.Tables[0];
datagrid1 = (DataTable)q2.Tables[0];
where content is a MySQL string and datagrid1 is a datatable.
FORM2:
private Form1 m_parent;
DataTable t = new DataTable();
public FORM2(Form1 frm1)
{
InitializeComponent();
m_parent = frm1;
}
private void FORM2_Load(object sender, EventArgs e)
{
this.dataGridView2.DataSource = m_parent.datagrid1;
dataGridView2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
}
At the moment it working fine but when I do some changes in datagridview2 it is also reflecting in datagridview1 of the main form (FORM1). Is it possible to make them independent as soon as the datagridview2 has the data?
Thanks,