Canceling Window Creation

  • Thread starter Thread starter Gary Brown
  • Start date Start date
G

Gary Brown

Hi,

If window creation cannot continue how is it cancelled within
an Load event handler? Setting DialogResult to Cancel
does nothing and Close() is not allowed. The form is shown
modelessly so returning a value directly to the parent is
meaningless.

I am using .NET 1.1.

Thanks,
Gary
 
You can't really close the form in the Load event but I've find this pattern
works. The form will start fully transparent, then after you've decided that
you want to show it you set the Opacity back to 100 and do your normal code.
If you decide not to show the form then use BeginInvoke call Close outside
the Load event.

Me.Opacity = 0
If <condition to close form> Then
Me.BeginInvoke(New MethodInvoker(Me.Close), Nothing)
Else
Me.Opacity = 100 ';
' regular form load code here
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top