I can not close the parent form and child form from the child form

0

I have a project that contains a login that when entering as an administrator, an MDI window is displayed, which is a configuration window and from there you can open the main window (both are open). In the main window I have a button that closes the session by going back to the login window and (what I want the software to do) closes the MDI and main windows, but only closes the main window and opens the login window. Probe performing an instance of the MDI window in the following way:

Dim panel As New Panel_MDI()
panel.Close()
Me.Close()

but this does not work for me.

I realized that when I made some adjustments, the instances of those forms started to fail. What you do is that, pass an argument from the login to the main screen, creating a New that receives arguments.

Private nombre As String

Public Sub New()

    InitializeComponent()

    abrir_controlProduccion()
    abrir_eTata()
End Sub

Public Sub New(ByVal nom As String)
    Me.New()
    nombre = nom
End Sub

That code is from the main form, the one from the MDI form is the same.

Can it be that when creating new instances I'm not closing the one I want but another one?

    
asked by Daniel Peña 05.07.2017 в 06:51
source

1 answer

0

I managed to solve the problem.

Actually I was not closing the same instance, so I modified the code to get the instance of the parent form in the following way:

In the MDI panel I add the following line to pass the instance from father to son.

Dim panel As New PanelPrincipal()
panel.Show(Me)

Then in the son he wrote the following code:

Login.Show()
CType(Me.Owner, Panel_MDI).Close()
Me.Close()
    
answered by 05.07.2017 в 08:39