Simply this: it's doing some validation concerning data that belongs to that
form, that I only want to read when the form is invoked. If validation fails
I want to issue a message and then close the form.
> As you can see from the controversial answers you raised, you may want to
> explain what you are trying to do exactly.
[quoted text clipped - 10 lines]
>> Application.Exit();
>> this.Close();
Vlado - 24 Mar 2006 13:26 GMT
> Simply this: it's doing some validation concerning data that belongs to
> that form, that I only want to read when the form is invoked. If
> validation fails I want to issue a message and then close the form.
You could do something like this:
YourForm yf = new YourForm();
if (yf.SomeMethodThatDoesValidation())
{
yf.Show();
}
else
{
this.DoSomethingElseInsteadShowingYourForm();
}
HTH
Patrice - 24 Mar 2006 15:18 GMT
As you create the form, you take those data from somewhere else ? Can't you
take them from the same location without invoking the form so that you can
test if you need to show or not this form.
It would seem cleaner to me than to create a form that would retrieve some
data in its constructor and would then kill itself based on some test...
Other options :
- You should be able to create the form without showing it. Some code may
help to understand what goes wrong...
- You could perhaps use DialogResult in the constructor and close the form
in the load event if the DialogResult has the "cancelled" value

Signature
Patrice
> Simply this: it's doing some validation concerning data that belongs to
> that form, that I only want to read when the form is invoked. If
[quoted text clipped - 14 lines]
>>> Application.Exit();
>>> this.Close();
Marc Gravell - 24 Mar 2006 15:53 GMT
Well, in the ctor, it hasn't yet been opened or shown, so there isn't much
to close; you could through an exception?
Marc
> Simply this: it's doing some validation concerning data that belongs to
> that form, that I only want to read when the form is invoked. If
[quoted text clipped - 14 lines]
>>> Application.Exit();
>>> this.Close();