Is it possible to close a window on the load event?
Printable View
Is it possible to close a window on the load event?
Yes.
wonderful!
how?
Is the 'window', another application?
Bruce.
Me.Close()
mendhak, that has no effect.
bruce fox, i have a window form and on its 'load' event i want to close it.
can somebody help me here pls?
huh? what is the purpose of running your program and then close it when it loads?
or am i missing something?
the Me.Close() that Mendhak mentioned should do it.Quote:
Originally Posted by dani2
Have you instantiated the Form from a Module?
In any event, please post the FormX Load Event code.
Bruce.
I have a test on the 'load' event. If it fails there's no point to display it.
Can I close it?? because Me.Close() does nothing :(
I can think of one example (I use it). When an app is opened, validate it for registration. If not valid display a dialog, and unload the Form.Quote:
Originally Posted by mar_zim
Bruce.
Quote:
Originally Posted by dani2
See my second post above (Post the Load Event code)
Bruce.
Ok. i found out why Me.close() is not working..
The 'Me' its a dialog :)
Now, is there any other way to close this dialog on its load event?
oh...he's talking about validation thingy. my bad.Quote:
Originally Posted by Bruce Fox
sorry.
:(
Is the 'Dialog' a Form you created, or is it the standard windows MsgBox/MessageBox?
Bruce.
I'm sure alot of people would have thought that after the first read :)Quote:
Originally Posted by mar_zim
The original question implied it too, I just supected that he/she had some idea what they wanted ;).
Bruce.
It is a form created that inheritsI open it withVB Code:
System.Windows.Forms.FormAnd i want to close it before it displays anything :)VB Code:
ShowDialog()
and yes, i do have some idea of what i want!
I may help if you post the code used to display that 'Dialog' Form.
And, the code in it's Load Event.
Bruce.
Really its very common code.
I open the form from another like this:
and in the load event its a simple test which returns true or false. if it's false i don't want to display the form.VB Code:
Dim dlgAbsences As EmployeeAbsences dlgAbsences = New EmployeeAbsences() dlgAbsences.ShowDialog()
Me.Close() is ignored..
Assuming that there is a reason you don't validate prior to loading the 'Dialog'; I'm at a loss as to why the .Close() dosn't work.
I dont have .Net on this PC, so I can;t test - sorry.
Bruce.
No problem. i will make the test prior as you suggested.
thank you
I just pulled the ol laptop out and did a test.
It was sucessfull using a 'windows' (2nd) Form.
I suspect that it is because you inherited the Form.
Just a guess tho :)
Bruce.
Is the window you want to close a form or what?
try formX.ActiveForm.close()
where formX is name of your form.