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. Passing Data from a Mdi Child form to its Parent form

Passing Data from a Mdi Child form to its Parent form

Scheduled Pinned Locked Moved C#
question
3 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.
  • J Offline
    J Offline
    joshp1217
    wrote on last edited by
    #1

    Okay i want to do this: Use the child's MDIParent property to get the parent form. Cast it to the MDI parent type. Then set/use the properties of the parent. What is the correct syntax because i keep getting Errors?

    L A 2 Replies Last reply
    0
    • J joshp1217

      Okay i want to do this: Use the child's MDIParent property to get the parent form. Cast it to the MDI parent type. Then set/use the properties of the parent. What is the correct syntax because i keep getting Errors?

      L Offline
      L Offline
      LongRange Shooter
      wrote on last edited by
      #2

      MyParent form = (MyParent)this.MDIParent;

      However, if you need to pass data from the child to the parent based on a user action, it is better to do it with events. This way you avoid casting and you do not risk changes to the parent form or its' children. Search MSDN and you will get a good tutorial on establishing events. The altered data can be in your custom event arguments.

      1 Reply Last reply
      0
      • J joshp1217

        Okay i want to do this: Use the child's MDIParent property to get the parent form. Cast it to the MDI parent type. Then set/use the properties of the parent. What is the correct syntax because i keep getting Errors?

        A Offline
        A Offline
        Al battashy
        wrote on last edited by
        #3

        There are different approaches, but I think this will assist Code for the Closing event of the Child form i.e. on closing the form; here is the code: In this code the frmMain is the MDIParent of the frmItem, but casting is important in retrieving the properties of the parent form: private void frmItem_FormClosing(object sender, FormClosingEventArgs e) { Form f = sender as Form; ((frmMain)f).statusStrip = frmItem.statusStrip; }

        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