Reputation: 171
I have a small requirement and that is as follows:
I have a login form and after a successful login, i open another MDI form, but i want to close the login form. I have given the code as:
MDIForm1.show
Me.Close
This does not seem to work.
Can anyone help on this.
Similarly, is is possible to open the login form on an inactive MDI form [MDI and Login for to be seen] and when th user login details are correct, it must close the login form and return to the MDI Form.
Please help on this.
Regards,
George
Upvotes: 1
Views: 1507
Reputation: 650
Other ways:
Dim <form name> As New <form name>
<form name>.Show()
Me.Hide()
Upvotes: 0
Reputation: 128417
Firstly, I'm guessing you've set your login form as the application's startup form? If so then VB has put something like this together for you behind the scenes:
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New LoginForm)
The magic happens there in that Application.Run
call, which basically creates a message loop for your GUI and terminates when it detects that your form has been closed.
There are a couple of ways that I know of to deal with this.
ShowDialog
on an instance of your login form before appearing.As for the MDI form question: this seems completely possible to me, if I understand you correctly. You want to show both the login form and the MDI form at once, but you want the MDI form to be disabled until the login form is closed, right?
So just make the MDI form your application's startup form, have it call ShowDialog
on your login form in its Load
event, and bingo: the MDI form will effectively be "locked" until the login form is dealt with (this is how modal dialogs in general such as MessageBox
work). This is actually the same as option #1 above except that the main form (your MDI form) is never hidden, only blocked.
Upvotes: 1