i want to Close FrmLogin while loading MDI FrmMain

palestine

Member
Joined
May 13, 2007
Messages
8
Programming Experience
1-3
plz Help Me
iwant Close Login Form while loading MDI Form
and i hope to update on my this example
 

Attachments

Last edited by a moderator:
Set the main form as startup form. In Application Startup event you show the login form as dialog and use e.Cancel to stop application from starting if login fails. There's a code example in post 4 of this thread: http://www.vbdotnetforums.com/showthread.php?t=19637
 
i found this code
where i add this code


Private Sub MyApplication_Startup(ByVal sender As Object, _
ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
If loginform.ShowDialog <> DialogResult.OK Then e.Cancel = True
End Sub
 
Don't you understand this explanation?
You get to the Application Events from main menu Project Properties, Application tab, click "View Application Events" button.
 
79366047.png
 
frmLogin does not start frmMain, so remove that code. When you find that user is valid login you set DialogResult=OK.
So you replace these lines:
VB.NET:
Expand Collapse Copy
                Me.Hide()
                Dim FrmMain As New FrmMain
                FrmMain.Show()
with this:
VB.NET:
Expand Collapse Copy
               DialogResult = Windows.Forms.DialogResult.OK
You have to remove the ShowInTaskbar statement in CustomizeForm method because it make it doesn't work.

Also you don't have to create a new frmlogin instance in MyApplication class, by just writing frmlogin.showdialog you are using the default instance.
 
Back
Top