can anyone do help..?
i really need help on this, here i have two forms [form1 & form2]. I have created datagridview(DGV) in each forms. Now i need to transfer/copy values from form2 datagridview to form1 datagridview by clicking one button on form2.
in form2 i wrote this..!
private void button1_Click(object sender, EventArgs e)
{
try
{
if (dataGridView1.RowCount != 0)
{
foreach (DataGridViewRow row in dataGridView1.SelectedRows)
{
object[] items = new object[row.Cells.Count];
for (int i = 0; i < row.Cells.Count; i++)
items[i] = row.Cells[i].Value;
Form1 F1 = new Form1();
F1.Activate();
F1.dataGridView1.Rows.Add(items);
F1.dataGridView1.DataSource = items;
dataGridView1.Rows.Remove(row);
}
}
else
{
MessageBox.Show("There is no data to export, please verify..!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch { }
}
and i'm getting error like "...dataGridView1.Form1 is inaccessible due to its protection level". Is there any other way or method to import values from form2 datagridview to form1 datagridview..?
any ideas...?
thanks in advance.