Public Class Main

    Private Sub ClientiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClientiToolStripMenuItem.Click, stripClienti.Click
        ShowForm(Clienti)
    End Sub

    Private Sub ImmobiliToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImmobiliToolStripMenuItem.Click, ToolStripButton1.Click
        ShowForm(Immobili)
    End Sub

    Private Sub stripFinestraCorrente_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles stripFinestraCorrente.SelectedIndexChanged
        Dim formName As String
        Dim form As Form

        formName = stripFinestraCorrente.Text
        form = My.Application.OpenForms(formName)
        If (form Is Nothing) Then
            stripFinestraCorrente.Items.Remove(stripFinestraCorrente.SelectedItem)
        Else
            form.Activate()
        End If
    End Sub

    Private Sub ShowForm(ByVal frm As Form)
        frm.MdiParent = Me
        frm.Show()
        stripFinestraCorrente.Items.Add(frm.Name)
    End Sub

    Private Sub AgentiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AgentiToolStripMenuItem.Click, stripAgenti.Click
        ShowForm(Agenti)
    End Sub

    Private Sub FotoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FotoToolStripMenuItem.Click
        ShowForm(Foto)
    End Sub
End Class