Answered go from one from to another

  • Monday, August 20, 2012 12:57 PM
     
     

    I have 3 forms lets say Form1, Form2 and Form3. Form1 is the MDIParent for Form2 and Form3 and I have already created the object of Form3 on the code behind code of Form1. Now I want to call one method of Form3 from Form2. How to do that, actually I don't want to create the object of Form3 again as it already exist.

All Replies

  • Monday, August 20, 2012 1:18 PM
     
     Answered

    If this is a Windows Forms applicaiton then the way to access a method on another form is to create a reference to that other form at the time that you create it, and use that reference to access the method.  In your case would pass that reference to Form3.  For instance:

    In Form1:

       Dim frm2 As New Form2
       frm2.Show
    ...

       Dim frm3 as New Form3(frm2)

    and in Form 3

        Dim frm2 as Form2

       Public Sub New (thisForm2 as Form2)
            InitializeComponent()
            frm2 = thisForm2
        End Sub

       ...

       frm2.Update

    If this is not a Windows Forms application then a different procedure would be used.