How cancel an OpenForm action from the form is openining

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I open a form:

Dim MyForm as New Form
Form.Show

After this i want to test some conditions in the form while it's opening and
I would cancel the show action if theese conditions aren't true.

Any ideas ???

Many thanks
nq
 
Nicola said:
Dim MyForm as New Form
Form.Show

After this i want to test some conditions in the form
while it's opening and I would cancel the show action
if theese conditions aren't true.

Add a shared factory method to your form class that will construct and
return the form only if the conditions are true:

\\\
Public Class Form1
Inherits Form
 
Thanks for Your answer...
Bye
nq

Herfried K. Wagner said:
Add a shared factory method to your form class that will construct and
return the form only if the conditions are true:

\\\
Public Class Form1
Inherits Form
.
.
.
Public Shared Function CreateInstance() As Form
If...Then
Return New Form1()
End If
End Function
End Class
..
..
..
Dim f As Form1 = Form1.CreateInstance()
If Not f Is Nothing Then
f.Show()
Else
...
End If
///
 
Back
Top