Hi all,
I have a 5 forms: frmLogin, frmOptionSelect, frmMenu, frmStaff and frmCompany
The first startup form is frmLogin. After login, user will go to frmOptionSelect. The code I made is Dim the frmOptionSelect as new form,show the form and Me.hide. This also I made in frmOptionSelect to call frmMenu.
Ok, on frmMenu I add 2 button; btnStaffDet and btnCompny. When user click btnStaffDet, I will call frmStaffDetails and place it onto the frmMenu. This is my code:
Private Sub btnStaffDet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStaffDet.Click
Dim frmStaffDet As New frmStaffDetails()
frmStaffDet.TopLevel = False
Me.Controls.Add(frmStaffDet)
checkOpenForm(frmStaffDet)
frmStaffDet.Show()
frmStaffDet.Location = New Point(2, 149)
End Sub
The
checkOpenForm is use to check which form is open on frmMenu.If there is any, it will close it and display the called form on it. This is the code for checking any opened form:
Private Sub checkOpenForm(ByRef openform As Windows.Forms.Form)
For i As Integer = My.Application.OpenForms.Count - 1 To 0 Step -1
If My.Application.OpenForms.Item(i) IsNot Me Then
My.Application.OpenForms.Item(i).Close()
End If
Next i
End Sub
Right now, could anyone lead me to the right code which it will only check the open form in frmMenu and not the whole apps? Because right now, when it check the open forms, it check the Login and Option Select form and because it only hide, it will close the forms but nothing displayed in Menu form. Please help..