From one form, another one is launched with the help of a similar code (in fact, a standard one):
private void Show_Click(object sender, EventArgs e) { Child form1 = new Child(); form1.ShowDialog(); } How to find out the type of the form that launched Child ? Based on this, the contents of the form Child should be determined.
Childcreates knows aboutChild, andChilddoes not know about the form / class that creates it. What happens ifChildis created in a class method that is not a form? Submit to the constructor of theChildclass, or set as its property, an indicator of the behavior ofChild. - IgorChild, and when you initializeChild'and use it? - ByulentShow_Click, and look, you have aShow_Clickmethod in which the object and the event arguments are passed as parameters. If you really need, you can pass data into your form through a constructor, and then use it like this:Child form1 = new Child(MyDataStruc Data);whereMyDataStrucis a structure / class with the data you need. Or simply pass the link to the parent. But here, too, has its own nuances. - BlackWitcher