title: How to prevent negative integers and blank inputs using DataError event in vb.net
body: <p>I have a datagridview bound to a dataset. My goal for my datagridview is to prevent the user from entering negative integers and leaving the datagridviewcell blank. I wish to have some sort of error message or message-box to tell the user that their entry is invalid. Here is what I have so far, hopefully it can give you a starting point. I greatly appreciate any help or suggestions you may give. </p>
  
  <pre><code>Private Sub DataGridView1_DataError(ByVal sender As Object, _
  ByVal e As DataGridViewDataErrorEventArgs) _
  Handles DataGridView1.DataError
  
      If  CInt(e.Exception.Message, "Input string was not in a correct format.") &lt; 0 Then
          MessageBox.Show("Please Enter a positive Value")
          'This will change the number back to original
          DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = " "
      End If
  </code></pre>