How to get values of form controls in MDI application?
-
Hi.. In an MDI application if i have a parent form & 2 child forms. In that application how i can get values of parent form controls(e.g. textbox text or a boolean variable) form child form & from child form how i can get values of parent form controls (e.g. textbox text or a boolean variable). Thanks, Vinay
-
Hi.. In an MDI application if i have a parent form & 2 child forms. In that application how i can get values of parent form controls(e.g. textbox text or a boolean variable) form child form & from child form how i can get values of parent form controls (e.g. textbox text or a boolean variable). Thanks, Vinay
You can use this fragment: YourForm frm; foreach( Form mdi in this.MdiChildren) { frm = mdi as YourForm; if( frm == null ) continue;//this is other form //frm.YourProperty; //frm.YourPublicFunction(); return; }
-
You can use this fragment: YourForm frm; foreach( Form mdi in this.MdiChildren) { frm = mdi as YourForm; if( frm == null ) continue;//this is other form //frm.YourProperty; //frm.YourPublicFunction(); return; }
Hi... I am trying what u suggested here & I think with this i can get Child form control values from Parent form but how i will get Parent form control values from child forms & values of controls in two child forms(say 2 child forms . Actually i have a password form as a child of a parent form & in parent i have a MenuStrip & i want to disable that Menustrip until user enters correct password in Password child form. Can u suggest anything for my application...? Thanks, Vinay
-
Hi... I am trying what u suggested here & I think with this i can get Child form control values from Parent form but how i will get Parent form control values from child forms & values of controls in two child forms(say 2 child forms . Actually i have a password form as a child of a parent form & in parent i have a MenuStrip & i want to disable that Menustrip until user enters correct password in Password child form. Can u suggest anything for my application...? Thanks, Vinay
Your LoginForm can use delegate to LoginMethod in MDIContainer Form. Until user not correct enter name and pwd, Menus will be not enabled. If you want, i create project 4 you. Sry 4 my English. Tom
-
Your LoginForm can use delegate to LoginMethod in MDIContainer Form. Until user not correct enter name and pwd, Menus will be not enabled. If you want, i create project 4 you. Sry 4 my English. Tom
Thanks for reply... if its Possible for you then you can create a project or tell me the logic i'll try... in my application after displaying the parent form i should display password form(Child form) on parent form with disabled MenuStrip. i just want to disable MenuStrip if i havnt not logged in my application(from my child PasswordForm)... Regards, Vinay
-
Thanks for reply... if its Possible for you then you can create a project or tell me the logic i'll try... in my application after displaying the parent form i should display password form(Child form) on parent form with disabled MenuStrip. i just want to disable MenuStrip if i havnt not logged in my application(from my child PasswordForm)... Regards, Vinay
there are two ways to achieve your aim. 1.Create an
public static bool LoginOk;
in you parent form and set its Value true or false as per your login result.and check this value just after you child window get close. 2.set DialogResult for your child window as per your login result.and check this value just after you child window get close. e.g;child.ShowDialog(); if(child.DialogResult==DialogResult.OK) { // Your Code } else { // Your Code }
sameer -
Hi.. In an MDI application if i have a parent form & 2 child forms. In that application how i can get values of parent form controls(e.g. textbox text or a boolean variable) form child form & from child form how i can get values of parent form controls (e.g. textbox text or a boolean variable). Thanks, Vinay
hi, you can get the values by assigning a get function as public for every textbox or label in each of the parent and child form. and send a reference for each form in the constructor. for example u can send a reference of the parent form in the constructor of the child form and using the get functions u can get the values respectivaly. hope it helps Jamil Abou Khalil
-
there are two ways to achieve your aim. 1.Create an
public static bool LoginOk;
in you parent form and set its Value true or false as per your login result.and check this value just after you child window get close. 2.set DialogResult for your child window as per your login result.and check this value just after you child window get close. e.g;child.ShowDialog(); if(child.DialogResult==DialogResult.OK) { // Your Code } else { // Your Code }
sameer -
i declared a varible(LoginOk) as you told in Parent form but can u tell me how i will change that value from child form. Thanks for your reply, Vinay
-
hi, you can get the values by assigning a get function as public for every textbox or label in each of the parent and child form. and send a reference for each form in the constructor. for example u can send a reference of the parent form in the constructor of the child form and using the get functions u can get the values respectivaly. hope it helps Jamil Abou Khalil