dataGrid and cellParsing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jay

    #1

    dataGrid and cellParsing

    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.parsingApplie d = 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?


  • ClayB

    #2
    Re: dataGrid and cellParsing

    Instead of CellParsing, try using CellValidating with code similar to
    this in the handler:

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

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

    Comment

    • jay

      #3
      Re: dataGrid and cellParsing

      Works great. Thanks for the assistance.

      "ClayB" <clayb@syncfusi on.comwrote in message
      news:1181910524 .420080.75570@g 4g2000hsf.googl egroups.com...
      Instead of CellParsing, try using CellValidating with code similar to
      this in the handler:
      >
      If e.FormattedValu e Is Nothing OrElse e.FormattedValu e = DBNull.Value
      OrElse e.FormattedValu e.ToString() = "" Then
      e.Cancel = True
      End If
      >
      ===============
      Clay Burch
      Syncfusion, Inc.
      >

      Comment

      Working...