Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to get values of form controls in MDI application?

How to get values of form controls in MDI application?

Scheduled Pinned Locked Moved C#
tutorialquestion
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IamHuM
    wrote on last edited by
    #1

    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

    T Q 2 Replies Last reply
    0
    • I IamHuM

      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

      T Offline
      T Offline
      tomasd_brn
      wrote on last edited by
      #2

      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; }

      I 1 Reply Last reply
      0
      • T tomasd_brn

        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; }

        I Offline
        I Offline
        IamHuM
        wrote on last edited by
        #3

        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

        T 1 Reply Last reply
        0
        • I IamHuM

          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

          T Offline
          T Offline
          tomasd_brn
          wrote on last edited by
          #4

          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

          I 1 Reply Last reply
          0
          • T tomasd_brn

            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

            I Offline
            I Offline
            IamHuM
            wrote on last edited by
            #5

            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

            S 1 Reply Last reply
            0
            • I IamHuM

              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

              S Offline
              S Offline
              sam
              wrote on last edited by
              #6

              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 1 Reply Last reply
              0
              • I IamHuM

                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

                Q Offline
                Q Offline
                quiteSmart
                wrote on last edited by
                #7

                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

                I 1 Reply Last reply
                0
                • S sam

                  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 Offline
                  I Offline
                  IamHuM
                  wrote on last edited by
                  #8

                  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

                  S 1 Reply Last reply
                  0
                  • I IamHuM

                    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

                    S Offline
                    S Offline
                    sam
                    wrote on last edited by
                    #9

                    one can access static variable with class name e.g public class Parent { public staic bool LoginOK; } //access it like Parent.LoginOK =true;

                    1 Reply Last reply
                    0
                    • Q quiteSmart

                      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

                      I Offline
                      I Offline
                      IamHuM
                      wrote on last edited by
                      #10

                      Thanks, I am new in C#...Can you told me little bit in detail... How to send ref of parent form in constructor of child form ...? regards, Vinay

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups