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.
 
Back
Top