Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Relating to a control within the active MDI child form 1

Status
Not open for further replies.

james0264

Programmer
Mar 1, 2005
52
GB
My program consists of a MDI Parent which needs to relate to the active child form. How do I achieve this, if I want to use the .GoBack() function on a web browser within the child if I click on a tool bar button in the parrent form. All I know how to use is Me.ActiveMdiChild. but it fails to work when I use Me.ActiveMdiChild.brwBrowser. statement. Many thanks, James.
 
I have been gob-smacked! Thank you TipGiver for giving this piece of code, here's a star!
 
I've have just changed all my code which needs to refer to the active MDI child to the code provided. But now I need to find a way of updating a control on the parent form from the active mdi child. Based on the code above, I have the following:
Code:
Dim frmParentForm As Form = Me.ParentForm
CType(frmParentForm.Controls("staStripProgress"), ToolStripProgressBar).Value = 0
This however gives me an error that "Value of type 'System.Windows.Forms.Control' cannot be converted to 'System.Windows.Forms.ToolStripProgressBar'." Any help? Many thanks in advance, James.
 
Hello!

Here is a way to do that:
* form1 is the mdi parent form

In form1 write:
Code:
    Public Property pbarValue() As Integer
        Get
            Return ToolStripProgressBar1.Value
        End Get
        Set(ByVal value As Integer)
            ToolStripProgressBar1.Value = value
        End Set
    End Property

Somewhere in the child form:
Code:
        Dim pf As Form = Me.MdiParent
        DirectCast(pf, Form1).pbarValue = 50

* NOTE that i do the directcast because i know that the mdi parent is form1.

----------
There is a similar way (to my preview post) to do that too. I think it is better to do that by a property.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top