Search code examples
c#.netwinformschildrenmdi

Multi child in MDI


I have multiple forms in MDI. I create the same child a few times, for instance 3 times. I have a data I want to send to the chosen child, but it always sends data to the latest child.

There is sample code:

f13 = new Excel_form(this, Convert.ToInt16(words[1].Substring(0, words[1].Length - 1)));
f13.MdiParent = this;
f13.FormClosed += new FormClosedEventHandler(f13_FormClosed);
f13.Show();

And function to send data:

f13.Odebrane(odebrane, ktory_form_pyta);

I want to send data to form chosen by myself. Something like this:

Form[] children = this.MdiChildren;
children[CHOSEN_CHILD].WindowState = FormWindowState.Normal;

It works for WindowState, but not for sending data. It is possible?


Solution

  • It should be casted to the class that Form is.

    MdiChildren is a collection of "Form", that won't have the method that you are trying to use.

    Something like (children[CHOSEN_CHILD] as Excel_form).Odebrane(odebrane, ktory_form_pyta);