Results 1 to 7 of 7

Thread: Access MDI parent control from MDI child[RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member usamaalam's Avatar
    Join Date
    Nov 2002
    Location
    Karachi
    Posts
    1,308

    Access MDI parent control from MDI child[RESOLVED]

    Hello everybody,

    From my MDI child form, I need to change the text property of statusbar panel of MDI parent.

    Thanks
    Last edited by usamaalam; Mar 1st, 2005 at 12:48 AM. Reason: RESOLVED

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: Access MDI parent control from MDI child

    Quote Originally Posted by usamaalam
    Hello everybody,

    From my MDI child form, I need to change the text property of statusbar panel of MDI parent.

    Thanks
    from the MDI child use this
    this.MdiParent.YouStatusBarsName....


    rate my posts
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3

    Thread Starter
    Frenzied Member usamaalam's Avatar
    Join Date
    Nov 2002
    Location
    Karachi
    Posts
    1,308

    Re: Access MDI parent control from MDI child

    I am unable to see status bar in MDIParent property of the child form.

  4. #4
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: Access MDI parent control from MDI child

    Quote Originally Posted by usamaalam
    I am unable to see status bar in MDIParent property of the child form.
    oh my bad! I wasnt thinking right

    VB Code:
    1. Dim frmParent As frmMdiParent
    2. frmParent = DirectCast(Me.MdiParent, frmMdiParent)
    3. frmParent.statusBarHere


    MdiParent property returns the form, but it returns it as a general form. You need to convert it to the the type of your main mdi form is called, and you do that by calling DirectCast as you see up there

    rate my posts
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  5. #5
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: Access MDI parent control from MDI child

    ah thought I'm in the vb.net forum. I leave that up for reference here's the c# version:

    Code:
    frmMdiParent frmParent = (frmMdiParent)this.MdiParent;
    frmParent.statusBar1.Text="DASFADSF";
    where frmMdiParent is the name of your mdi form, and you put this code in the mdi child form.
    One thing I just noted is that apparently in C# controls and things you put on the form are declared as private, so you need to manually change the code that VS.NET generates. In your mdi form, if you search for the name of your statusbar you should see a line like this near the top of the class:
    private System.Windows.Forms.StatusBar statusBar1;
    you need to change the private to public in order for you to be able to access it through the mdi child

    HTH

    rate my posts
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  6. #6

    Thread Starter
    Frenzied Member usamaalam's Avatar
    Join Date
    Nov 2002
    Location
    Karachi
    Posts
    1,308

    Re: Access MDI parent control from MDI child

    Thanks. I made a little conversions for C#. Now this works for me.

  7. #7
    New Member
    Join Date
    Dec 2011
    Posts
    1

    Re: Access MDI parent control from MDI child[RESOLVED]

    Thank you so much, i searched too much for this but not one was able to help me, by chance i visited ur reply and got the solution.....
    Good work done...
    Thanks

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