This is what i want to do . There is a datagridview inside a panel, this panel is inside a tabPage within a tabcontrol and this tabcontrol is in the Form1.
Form1 --> TabControl --> tabPage --> panel --> **DATAGRIDVIEW**
From my main form, I call Form2 such as Form2.Show() in which the user will input something then if the user click the button lets say "save changes" , the Form 2 will close and in the Form1, i want the datagrid to be updated. when the user clicked the button in Form2 Save Changes. Here's the code:
In Form1:
private void btnEditItem_Click(object sender, EventArgs e)
{
Form3 form3 = new Form3();
Form1 frm = this.MdiParent as Form1;
form3.Show();
this.Hide();
}
In the second Form:
private void flatButton1_Click(object sender, EventArgs e)
{
DialogResult dr = MessageBox.Show("Save Changes?", "Confirmation", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
Form form1 = (Form)this.MdiParent;
DataGridView dt = (DataGridView)form1.Controls["flatTabControl1"].Controls["tabPage5"].Controls["panelUpdateRequest"].Controls["dataGridRequestItemsUpdate"];
dt.Rows[0].Cells[0].Value = "Plsss";**
this.Hide();
form1.Show();
}
}
The Error:
Datagridview dt = (DataGridView)..Null Reference Exception.