[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

me.close closes both open forms

I have a form that is an mdichild of another form. from this form i open another form with showDialog() in this form i call me.close and it closes both itself and the formt hat i opened it from


can anybody explain why?? :o(
0
ict-torquilclark
Asked:
ict-torquilclark
1 Solution
 
jppintoCommented:
I use the following function to open MDI forms. To call it I just use like this:

Call OpenMDIForm(New frmCarsList(), Me)

On the frmCarsList, I put this on the Close button click:

Private Sub btnSairform_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSairform.Click
        Me.Close()
    End Sub

And it just works fine for me.

jppinto
Public Sub OpenMDIForm(ByVal frmName As Form, ByVal frmParent As Form, Optional ByVal frmTag As Integer = 0, Optional ByVal frmDuplicates As Boolean = False)
        Dim IsLoaded As Boolean = False
        Dim frm As Form

        On Error Resume Next

        ' Case it doesn't allow duplicates
        If Not frmDuplicates Then
            ' Checks if the form is already opened
            For Each frm In frmParent.MdiChildren
                If frm.Name = frmName.Name Then
                    IsLoaded = True
                    Exit For
                End If
            Next
        End If

        ' Case it's not open
        If Not IsLoaded Then
            frmName.MdiParent = frmParent

            ' Put the value on the Tag of the new form
            If frmTag > 0 Then frmName.Tag = frmTag
            frmName.Show()

        Else
            frmName.Focus()
        End If

        frmName = Nothing
        frm = Nothing
    End Sub

Open in new window

0
 
CodeCruiserCommented:
>i open another form with showDialog() in this form i call me.close and it closes both itself and the formt hat i opened it from

You mean you call the me.Close on dialog form? Try setting the me.DialogResult

Show us the code you are using to show the dialog.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now