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. MDI; Finding a property on parent from MDI child form

MDI; Finding a property on parent from MDI child form

Scheduled Pinned Locked Moved C#
helptutorial
10 Posts 3 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
    ianhunt01
    wrote on last edited by
    #1

    Hi, I have got a MDI app where one of the childforms must be able to see the status of a RadioButton on a docked panel on the MDI from. I want too use the mousedown event on a child frmShow to draw lines on the form if the radPoly was clicked on the pnlTools on the parent MDI form. Please help with a simple code example. Thanks Ian

    M L 2 Replies Last reply
    0
    • I ianhunt01

      Hi, I have got a MDI app where one of the childforms must be able to see the status of a RadioButton on a docked panel on the MDI from. I want too use the mousedown event on a child frmShow to draw lines on the form if the radPoly was clicked on the pnlTools on the parent MDI form. Please help with a simple code example. Thanks Ian

      M Offline
      M Offline
      Mark Miller
      wrote on last edited by
      #2

      Ian, It isn't a real simple example, but you could take a look at my Extensions to DrawTools[^] article which has the type of ability (and more) you are looking for. In that application, the MDI parent form sets properties on the DrawArea object to communicate settings from parent to child. HTH

      Sincerely, -Mark mark@msdcweb.com http://www.msdcweb.com

      I 1 Reply Last reply
      0
      • I ianhunt01

        Hi, I have got a MDI app where one of the childforms must be able to see the status of a RadioButton on a docked panel on the MDI from. I want too use the mousedown event on a child frmShow to draw lines on the form if the radPoly was clicked on the pnlTools on the parent MDI form. Please help with a simple code example. Thanks Ian

        L Offline
        L Offline
        led mike
        wrote on last edited by
        #3

        ianhunt01 wrote:

        I have got a MDI app where one of the childforms must be able to see the status of a RadioButton on a docked panel on the MDI from.

        Why? Best Practice would be for views to get their data from the Model rather than another View. See Model-View-Controller[^]

        led mike

        I 1 Reply Last reply
        0
        • L led mike

          ianhunt01 wrote:

          I have got a MDI app where one of the childforms must be able to see the status of a RadioButton on a docked panel on the MDI from.

          Why? Best Practice would be for views to get their data from the Model rather than another View. See Model-View-Controller[^]

          led mike

          I Offline
          I Offline
          ianhunt01
          wrote on last edited by
          #4

          No, I had a look at the Wiki and it does not tell me much in a practical way of achieving this. But thanks in any case Ian

          L 1 Reply Last reply
          0
          • M Mark Miller

            Ian, It isn't a real simple example, but you could take a look at my Extensions to DrawTools[^] article which has the type of ability (and more) you are looking for. In that application, the MDI parent form sets properties on the DrawArea object to communicate settings from parent to child. HTH

            Sincerely, -Mark mark@msdcweb.com http://www.msdcweb.com

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

            Thanks Mark, Nice app and very usefull info for something else that I want to do but no MDI stuff in there ? cheers Ian

            M 1 Reply Last reply
            0
            • I ianhunt01

              No, I had a look at the Wiki and it does not tell me much in a practical way of achieving this. But thanks in any case Ian

              L Offline
              L Offline
              led mike
              wrote on last edited by
              #6

              ianhunt01 wrote:

              No, I had a look at the Wiki and it does not tell me much in a practical way of achieving this.

              Ok, I guess unless you can copy/paste some code you can't do it. Good luck.

              led mike

              1 Reply Last reply
              0
              • I ianhunt01

                Thanks Mark, Nice app and very usefull info for something else that I want to do but no MDI stuff in there ? cheers Ian

                M Offline
                M Offline
                Mark Miller
                wrote on last edited by
                #7

                Ian, The DrawTools project uses a MDI parent form - I had forgotten it doesn't use any child forms. Try this out for a solution to your problem: In your child form expose some public or internal properties that are set when a toolbar button in the parent form is clicked. For example: *** child form *** public bool isPoly; *** parent form *** In the toolbarButton_Click(...) event:

                if (ActiveMdiChild == null) return;
                var child = ActiveMdiChild as childformclass;
                child.isPoly = toolbarButton.Checked;

                This way the child form(s) can see when a button on the toolbar in the parent is checked or not and react accordingly. Additionally in the parent form you will want to react when the child form changes and set the state of buttons according to the active child form: *** parent form *** In MdiChildActivate event:

                if (ActiveMdiChild == null) return;
                var child = ActiveMdiChild as childformclass;
                toolbarButton.Checked = child.isPoly;

                HTH

                Sincerely, -Mark mark@msdcweb.com http://www.msdcweb.com

                I 1 Reply Last reply
                0
                • M Mark Miller

                  Ian, The DrawTools project uses a MDI parent form - I had forgotten it doesn't use any child forms. Try this out for a solution to your problem: In your child form expose some public or internal properties that are set when a toolbar button in the parent form is clicked. For example: *** child form *** public bool isPoly; *** parent form *** In the toolbarButton_Click(...) event:

                  if (ActiveMdiChild == null) return;
                  var child = ActiveMdiChild as childformclass;
                  child.isPoly = toolbarButton.Checked;

                  This way the child form(s) can see when a button on the toolbar in the parent is checked or not and react accordingly. Additionally in the parent form you will want to react when the child form changes and set the state of buttons according to the active child form: *** parent form *** In MdiChildActivate event:

                  if (ActiveMdiChild == null) return;
                  var child = ActiveMdiChild as childformclass;
                  toolbarButton.Checked = child.isPoly;

                  HTH

                  Sincerely, -Mark mark@msdcweb.com http://www.msdcweb.com

                  I Offline
                  I Offline
                  ianhunt01
                  wrote on last edited by
                  #8

                  Thanks Mark, This was really helpfull !! I used to work in VB6 Pro and thought about moving over to C#.Net instead of VB.Net. In order to learn the new C#.Net environment it seems you have to buy a lot of books (four up to date) and do the Microsoft certified courses and still all of it only shows you bits and pieces and end up becoming very expensive. So what I am trying to say is that the code you supplied helps me a lot in grasping whats happening. So thanks again for your patience. Ian

                  M 1 Reply Last reply
                  0
                  • I ianhunt01

                    Thanks Mark, This was really helpfull !! I used to work in VB6 Pro and thought about moving over to C#.Net instead of VB.Net. In order to learn the new C#.Net environment it seems you have to buy a lot of books (four up to date) and do the Microsoft certified courses and still all of it only shows you bits and pieces and end up becoming very expensive. So what I am trying to say is that the code you supplied helps me a lot in grasping whats happening. So thanks again for your patience. Ian

                    M Offline
                    M Offline
                    Mark Miller
                    wrote on last edited by
                    #9

                    Ian, You are very welcome - glad I was able to help. I came to C# after making a living programming in Visual FoxPro for close to 10 years. I picked up some Java experience along the way as well. When I started learning .NET and C# I too bought several books - the best one for me was Windows Forms 2.0 Programming[^]. Hang in there and don't be afraid to ask questions on CodeProject - everyone here is very helpful.

                    Sincerely, -Mark mamiller@rhsnet.org

                    I 1 Reply Last reply
                    0
                    • M Mark Miller

                      Ian, You are very welcome - glad I was able to help. I came to C# after making a living programming in Visual FoxPro for close to 10 years. I picked up some Java experience along the way as well. When I started learning .NET and C# I too bought several books - the best one for me was Windows Forms 2.0 Programming[^]. Hang in there and don't be afraid to ask questions on CodeProject - everyone here is very helpful.

                      Sincerely, -Mark mamiller@rhsnet.org

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

                      Thanks Mark, The book looks good and I will amazon it soon !! Cheers Ian

                      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