Dialog Form

  • Thread starter Thread starter Jim Heavey
  • Start date Start date
J

Jim Heavey

Hello, there is something that I am forgetting, I just don't remember what
is.

I create a form which will server as a dialog box.
I set the "CancelButton", "AcceptButton" and the "FormBorderStyle =
"FixedDialog" for the properties of the form.

When the user presses the "Accept" button, I do some editing so see if the
data is acceptable. When the data is NOT acceptable, I think I am suppose
to set some property on the form? which will not allow the dialog box to be
closed. As of now, when I find an error, the machine just locks up.

What am I suppose to set to set the DialogResults and/or cause the form not
to close?


Thanks in advance for your assistance!!!!!!!!
 
Jim:

It depends. You can use the event args and see to it that the user doesn't
leave the form, but that could cause you some problems. I'd recommend using
the Validating event of your controls and disable the OK button that's
mapped to the forms Accept button until you know you have good data. At
that point, the user Clicks OK and you're good to do. Validating however,
depending on how it's used can cause the user to not be allowed to leave the
control, so it really depends on how you want to enforce conforming data.
In general, I think disabling the Ok button and only enabling it is a very
easy way to do what you want. Typically, users find it irritating if they
have no cancel option on a Dialog b/c they may not know what to enter and
just want to back out until later for instance.

If everything is freezing up though, I'd really look into why. If I
understood correctly, that doesn't sound like it's related to the
DialogResult issue but the above method should work for you.

HTH,

Bill
 
Back
Top