DataGridViewDataErrorEventArgs ?

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

Guest

Hi,

For the "DataError" event of the DataGridView I would like to catch the
"ConstraintException" when there is an error but I havent figure it out how
to do it with e.Exception of DataGridViewDataErrorEventArgs.

Thanks in advanced for any help,

Regards,
Asaf
 
Hi Asaf,

Thanks for posting.

Regarding this issue, we can use C# "is" operator to determine if
e.Exception is of type ConstraintException. Code snippet listed below:

if ((e.Exception) is ConstraintException)
{
DataGridView view = (DataGridView)sender;
view.Rows[anError.RowIndex].ErrorText = "an Constraint error";
view.Rows[anError.RowIndex].Cells[e.ColumnIndex].ErrorText = "an
Constraint error";
e.ThrowException = false;
}//what ever statement you like

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

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