I am trying to pass some strings(device info) from the parent form(the main form )in MDI to the child form
- The child form displays
- Device name
- Device model number
- Manufactured date,
- All these features should be passed to the child form when the ON button in the parent form is being clicked.
- The child form is called through the menu.
- Till now I have had success in only calling the child through the menu but cannot pass the data.
Parent Form: menu to view the child form on the MDI(parent form) whenever I want to
private void DeviceInfomationToolStripMenuItem_Click(object sender, EventArgs e)
{
if (Application.OpenForms["Child"] is Child deviceInfo)
{
deviceInfo.Focus();
return;
}
deviceInfo = new Child();
deviceInfo.MdiParent = this;
deviceInfo.Show();
}
Parent From: On button event
private void btnOn_Click(object sender, EventArgs e)
{
deviceName = "Notebook520220624";
deviceModel = "520220627";
manuFacturedDate = "220627";
Child form = new Child(deviceName);
}
Child Form: Receiving the device info and displaying it
public Child(string deviceName)
{
InitializeComponent();
name_lbl.Text = deviceName
//name_lbl.Text = deviceName.ToString();
//model_lbl.Text = diviceModel;
//date_lbl.Text = manuFacturedDate;
}