Results 1 to 6 of 6

Thread: Using the MDI Parent from a Child Form

  1. #1

    Thread Starter
    Junior Member Tekmaven's Avatar
    Join Date
    Jun 2002
    Posts
    18

    Using the MDI Parent from a Child Form

    There are two forms in my project, frmParent (the MDI Parent) and frmChild (the MDI Child). On frmParent there is a status bar. How do I change the properties of the status bar from a child form (frmChild)?
    PC Mod Kingdom powered by ASP.NET - Your source for all PC Mod Info!

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Not 100% sure, but isn't there a parent property of the MDI child form?

    Try something like this in the Child form:
    Me.Parent.theProgressBar

    You might need to set the progressbar to public in order to access it.

    I can't verify this stuff right now, I am not at a machine with .Net installed.

  3. #3
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Another thing to try, is if you can't get
    Me.Parent.theProgressBar
    to work is to try to cast the parent into a local object.
    Example:

    Dim frm As frmParent
    frm = Me.Parent

    Then use the frm varible to access the progress bar.
    frm.ProgressBarName

  4. #4

    Thread Starter
    Junior Member Tekmaven's Avatar
    Join Date
    Jun 2002
    Posts
    18
    Nope, the closest thing to Me.Parent is Me.ParentForm, and the app errors if I do the following:

    Me.ParentForm.StatusBar1.Text = "Yay, this finally worked"

    The error, StatusBar1 is not contained within System.Forms.Form (or something similar).
    PC Mod Kingdom powered by ASP.NET - Your source for all PC Mod Info!

  5. #5
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    To get to the statusbar you of course have to reference the Main form in any way but to get a variable "to know" what controls are on the form you have to declare one as the Main form. Uhhh taht sounded like it didn't make sence..... I'll try with an example:

    Code:
    Dim frm As frmMain = Me.ParentForm
    frm.sbMain.Text = "Schnabel"
    That should work.....

    What I was trying to say in the beginning was that if you use only Me.ParenForm. then the application can't determine what kind of form is your parent form, so it does not know what controls are listed in the form, but as you declare it (Dim frm As frmMain) the application knows it is an instance of the mainform and also then knows that there is a Statusbar on it. If you don't declare the form the application only knows that it is a Parentform, not what kind of form it is.
    Last edited by Athley; Jan 7th, 2003 at 03:51 AM.

  6. #6

    Thread Starter
    Junior Member Tekmaven's Avatar
    Join Date
    Jun 2002
    Posts
    18
    Grand it works! Thanks for you're help!
    PC Mod Kingdom powered by ASP.NET - Your source for all PC Mod Info!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width