.NET MDI App.

Discussion in 'AutoCAD' started by HJohn, Jul 19, 2004.

  1. HJohn

    HJohn Guest

    Can someone give me some help here? I have a MDI app. and I can't find the way to access the parent form to retrieve a value (Public variable). I can access the "MDIParent" with all it's properties and methods, but not a local variable. How can you get values stored on the parent from the child forms?
    Thanks in advance.
     
    HJohn, Jul 19, 2004
    #1
  2. HJohn

    Norman Yuan Guest

    You can cast the MDIParent. Say, the MDI container form is called frmMain,
    and looks like

    public class frmMain : Form
    {
    private int mVal=0;

    public frmMain(...)

    //Public property
    public int Val
    {
    get { return mVal; }
    }

    //Public method
    public void DoSomething()
    {

    }
    }

    Some where in the child form code, you can

    //Cast MDIParent as frmMain
    frmMain f=(frmMain)this.MDIParent;

    //Then access frmMain's property/method
    int myInt=f.Val;
    f.DoSomething();

    way to access the parent form to retrieve a value (Public variable). I can
    access the "MDIParent" with all it's properties and methods, but not a local
    variable. How can you get values stored on the parent from the child forms?
     
    Norman Yuan, Jul 20, 2004
    #2
  3. HJohn

    HJohn Guest

    Thanks for you help. Is that the only way of passing values between parent and child forms?
     
    HJohn, Jul 20, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.