Results 1 to 2 of 2

Thread: ParentForm

  1. #1

    Thread Starter
    Hyperactive Member Janaka's Avatar
    Join Date
    Nov 2001
    Posts
    277

    Smile ParentForm

    I created 2 forms formA and formB.
    FormB is created by formA.
    I need to refer to formA from formB.
    There is this property called “ParentForm” can that be used?

    Janaka

  2. #2
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    The ParentForm property gets the parent of a MDI child.

    A way for you migth be to keep a reference. You could do that by creating your own Sub New for your FormB where you pass a reference to the Form as an argument.

    Code:
    #Region " Windows Form Designer generated code "
    
        Dim mainForm As FormA
    
        Public Sub New(ByVal mForm)
            MyBase.New()
    
            'This call is required by the Windows Form Designer.
            InitializeComponent()
    
            'Add any initialization after the InitializeComponent() call
            mainForm = mForm
    
        End Sub
    You then use something like this from FormA:

    Code:
    Dim frm As New FormB(Me)
    frm.Show()
    You then have a reference to the Form via the mainForm variable.

    /Leyan

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