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 Question

MDI Question

Scheduled Pinned Locked Moved C#
tutorialquestion
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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Silly question probably, but...Whats the easiest way to communicate from a child Window to a parent window. For example, when the app starts, I want a login form to popup. When entered, that data needs to be available throughout the app. Currently I am using the "OnMdiChildActivate" event on the parent window which works, but it seems as if there should be a better way. Cody C

    D 1 Reply Last reply
    0
    • L Lost User

      Silly question probably, but...Whats the easiest way to communicate from a child Window to a parent window. For example, when the app starts, I want a login form to popup. When entered, that data needs to be available throughout the app. Currently I am using the "OnMdiChildActivate" event on the parent window which works, but it seems as if there should be a better way. Cody C

      D Offline
      D Offline
      Don_s
      wrote on last edited by
      #2

      You could do this in a couple of ways. If you are in full control of the form that is poping up, you can get the required information by capturing the OnClosing event of the logon form, add the event handler in your MDI parent's load event when you open the mdi child:

        //initialise the logon form
        LogonForm f = new LogonForm();
        //Set as child
        f.MdiParent = this;
        //Add event handler
        f.OnClosing += new EventHandler(this.Form1_Closing);
      

      Having done this, write code along these lines to capture properties from the closing logon form:

      private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
      {
        LogonForm f = (LogonForm)sender;
        string Uname = f.Username;
        string Pword = f.Password;
      }
      

      obviously you'll need to set up properties such as Username & Password in you logon form that are public. An other way may be to pass up a custom Logon class from the Parent to the child by reference, you can then populate it from the logon form and the information will be available to the parent. Let me know if you'd like me to elaborate on either of these methods.

      C 1 Reply Last reply
      0
      • D Don_s

        You could do this in a couple of ways. If you are in full control of the form that is poping up, you can get the required information by capturing the OnClosing event of the logon form, add the event handler in your MDI parent's load event when you open the mdi child:

          //initialise the logon form
          LogonForm f = new LogonForm();
          //Set as child
          f.MdiParent = this;
          //Add event handler
          f.OnClosing += new EventHandler(this.Form1_Closing);
        

        Having done this, write code along these lines to capture properties from the closing logon form:

        private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
          LogonForm f = (LogonForm)sender;
          string Uname = f.Username;
          string Pword = f.Password;
        }
        

        obviously you'll need to set up properties such as Username & Password in you logon form that are public. An other way may be to pass up a custom Logon class from the Parent to the child by reference, you can then populate it from the logon form and the information will be available to the parent. Let me know if you'd like me to elaborate on either of these methods.

        C Offline
        C Offline
        codycaillet
        wrote on last edited by
        #3

        Thanks..thats an interesting idea. I actually did it a different way by when the user logs on successfully, having the child window (logon form) populate some public properties of the parent window. I like the idea of having the parent window handle events of the login window however.

        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