winforms - Multiple child and parent form in C# -
i have 6 forms (let f1,f2,f2a,f2b,f2c,f2d)
i'm trying make f2a - f2d childs of f2 while f2 parentform f1 , f1 child form f2
what i've tried
f1
private void button1_click(object sender, eventargs e) { f2 nx = new f2(this); this.visible = false; nx.visible = true; }
f2
public f2(f1 parentform) { initializecomponent(); this.of = parentform; f2a na = new f2a(this); //it give me error describe down there. } public f1 of;
f2a - f2d
public f2* (f2 parentform) //well lets * stand letter of each form { initializecomponent(); this.of = parentform; } public f2 of;
on f2 gives me 2 error
1.the best overloaded method match 'gui_x.f2a.f2a(system.windows.forms.f2)' has invalid arguments
2.argument 1: cannot convert 'gui_x.f2' 'system.windows.forms.mainmenu'
so why isn't work f2 f2a - f2d while it's work f1 f2 ? wrong put ?how can resolve ?
i'm new c# , grateful if me , explain easy possible.
and if i'm using windows form project.
thankyou in advance.
edit
i'm sorry,i'm forgot initialize of in f2*'s,thanks @s_i_r answer. still won't resolve problem
would please verify type of this.of f2 in f2* classes
public f2* (f2 parentform) { initializecomponent(); this.of = parentform; } private f2 of; //make sure f2 not f1 or other
edit:
just declare f2a-f2d private object in f2 class when needed show them
public class f2 { private f2a f2a; private f2b f2b; public f1 of; public f2(f1 parent) { initializecomponent(); this.of = parent; f2a = new f2a(this); f2b = new f2b(this); } // call f2a - f2d method public void showf2a() { f2a.showdialog(); }
Comments
Post a Comment