dataGrid and cellParsing

  • Thread starter Thread starter jay
  • Start date Start date
J

jay

OK, I have a databound grid. I can stop the user from deleting a price by
capturing the cellParsing event, but what do I do after that? I have set
e.parsingApplied = false, but that does not prevent the user from pressing
the Save button, which is when I see the error message: "The following
exception occurred in the dataGridView" Price does not allow nulls... Whats
the Best Practice for handling these kinds of issues?
 
Instead of CellParsing, try using CellValidating with code similar to
this in the handler:

If e.FormattedValue Is Nothing OrElse e.FormattedValue = DBNull.Value
OrElse e.FormattedValue.ToString() = "" Then
e.Cancel = True
End If

===============
Clay Burch
Syncfusion, Inc.
 

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