I am writing an industrial program in c#. Since there are too many operations in the program, I placed multiple forms inside the form on the main page. But I cannot make any changes to the Main form using any control in the sub-form. What is the reason? Should I use Invoke?
This is my main form :
private void frmMain_Shown(object sender, EventArgs e)
{
frmMeasure frmMeasure = new frmMeasure();
frmMeasure.TopLevel = false;
frmMeasure.Dock = DockStyle.Fill;
frmMeasure.Visible = true;
pnlMain.Controls.Clear();
pnlMain.Controls.Add(frmMeasure);
}
This is sub-form and not working .
private void btnSettings_Click(object sender, EventArgs e)
{
frmMain frmMain = new frmMain();
frmProductSettings frmProductSettings = new frmProductSettings();
frmProductSettings.TopLevel = false;
frmProductSettings.Dock = DockStyle.Fill;
frmProductSettings.Visible = true;
frmMain.pnlMain.Controls.Clear();
frmMain.pnlMain.Controls.Add(frmProductSettings);
}
My aim is to change the sub-forms by using the button in the sub-form that I opened in the main form. Thank you.