J
JR
Hello,
I have a textbox in a form in which I would like to validate the user data.
If it is too long I want to pop up a messagebox. Here is the code:
private void txtDesc_Validating(object sender,
System.ComponentModel.CancelEventArgs e)
{
if (txtDesc.Text.Length > 60)
{
MessageBox.Show("Please enter a description of 60 characters or
less", "Error");
}
}
The problem is if the user enters text greater than 60 characters and then
clicks on the 'X' to close the form, this event fires and a messagebox still
pops up. I would like to determine if the form is closing when this event
fires and suppress the messagebox. I have tried working with the form's
Closing event and Focused property to no avail.
Any help appreciated.
Thanks.
JR
I have a textbox in a form in which I would like to validate the user data.
If it is too long I want to pop up a messagebox. Here is the code:
private void txtDesc_Validating(object sender,
System.ComponentModel.CancelEventArgs e)
{
if (txtDesc.Text.Length > 60)
{
MessageBox.Show("Please enter a description of 60 characters or
less", "Error");
}
}
The problem is if the user enters text greater than 60 characters and then
clicks on the 'X' to close the form, this event fires and a messagebox still
pops up. I would like to determine if the form is closing when this event
fires and suppress the messagebox. I have tried working with the form's
Closing event and Focused property to no avail.
Any help appreciated.
Thanks.
JR