c# - Accessing the parent Form -


i know title might seem silly, couldn't think of better, sorry.

i have 2 forms (c#), main-form holds instance of second. there way to.. access running instance of form1 (the entry point) , properties instance of form2?

everybody tells me learn oop. did, long long time ago, , still don"t it.

you instanciated form2 within form1. after instanciating , before showing set property on form2 refers form1 this:

form2 f2 = new form2(); f2.theparent = this; f2.show(); 

of course have add theparent property form2 class able that.

warning: although possible way better solution might create seperate object holds required/shared data andd pass object each form in similar way. prevent code becoming coupled.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -