-1

I created Mdi form now I want pass parameter 1 form to another without open form.

eg: both form open pass parameter each other.

my code working when

frmMain mainf = new frmMain();
mainf.rfidPort = mCobPort.SelectedItem.ToString();
mainf.tsslCom.Text = mCobPort.SelectedItem.ToString();
mainf.ShowDialog();

but my target appear to form A -> form B without form open. I don't want use code below:

mainf.ShowDialog();

Possible?

I cannot find my request in google. If Possible how? Please guide me. enter image description here

user3538475
  • 83
  • 1
  • 12

1 Answers1

0

The easiest (and least elegant way) is simply to update it directly in your click handler.

In your "Save Setting" form, handle the Submit click event by updating the parent form, which in this case is frmMain.

void Submit_Click(object sender, EventArgs e)
{
    var mainForm = this.Parent as frmMain;
    mainForm.rfidPort = this.mCobPort.SelectedItem.ToString();
}
John Wu
  • 50,556
  • 8
  • 44
  • 80
  • System.NullReferenceException: 'Object reference not set to an instance of an object.' Error Prompt – user3538475 Dec 29 '20 at 09:46
  • I’m guessing you did not set the form’s parent, or SelectedItem is null because no selection has been made. – John Wu Dec 30 '20 at 02:23