Hola, alguien sabe como puedo saber si un formulario esta cargado..
Tengo un ListView con un listado de Clientes.
Dim myForm As New frmCliente
With myForm
.Show()
End With
Lo que deseo saber es cargar un formulario por cliente. Es decir, si el cliente1 ya esta cargado en el FrmCliente. pues no dejar cargar otras ves.
En VB.60 se podía hacer con la coleccion Forms, pero en VB.Net no hay.
Alguna idea....
Nota: los formularios cliente no estan en un MDI
Saludos,
List(Of Form) m_myFormLists = new List(Of Form)
Con eso tienes la lista de forms :)
Después de una semana googleando finalmente los he resuelto. Para lo que necesiten...
Dim IsFormLoaded As Boolean = False
Dim myFrm As Form
For Each myFrm In Me.MdiChildren
If myFrm.Name = "frmBuscado" Then
If myFrm.WindowState = FormWindowState.Minimized Then
myFrm.WindowState = FormWindowState.Normal
Else
myFrm.BringToFront()
End If
IsFormLoaded = True
Exit For
End If
Next
myFrm = Nothing
If IsFormLoaded = False Then
Dim myFrmBuscado As New frmBuscado
With myFrmBuscado
.MdiParent = Me
.Show()
End With
myFrmBuscado = Nothing
End If
Si desean buscar en todos los formularios reemplacen:
Me.MdiChildren
por Application.OpenForms
Saludos,