ComponentOne True DBGrid for WinForms
True DBGrid for WinForms Task-Based Help / Adding Custom Error Checking to C1TrueDBGrid
In This Topic
    Adding Custom Error Checking to C1TrueDBGrid
    In This Topic

    C1TrueDBGrid displays a message for any errors that occur when building a project. You must switch off the internal error handling.

    Complete the following steps:

    1. To do this, set the Handled property to True in the Error event of the grid. It will switch off the grid's built-in error checking:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Private Sub C1TrueDBGrid1_Error(ByVal sender As Object, ByVal e As C1.Win.C1TrueDBGrid.ErrorEventArgs) Handles C1TrueDBGrid1.Error
          e.Handled = True
      End Sub
      

      To write code in C#

      C#
      Copy Code
      private void c1TrueDBGrid1_Error(object sender, C1.Win.C1TrueDBGrid.ErrorEventArgs e)
      {
          e.Handled = true;
      }
      
    2. You can then add your own error-handling code. For example:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Private Sub C1TrueDBGrid1_Error(ByVal sender As Object, ByVal e As
      C1.Win.C1TrueDBGrid.ErrorEventArgs) Handles C1TrueDBGrid1.Error
          If C1TrueDBGrid1.Columns(C1TrueDBGrid1.Col).DataField = "CategoryID" Then
              e.Handled = True
              MessageBox.Show("Your User Friendly Message")
          Else
              e.Handled = False
              MessageBox.Show("Enter a string")
          End If
      End Sub
      

      To write code in C#

      C#
      Copy Code
      private void c1TrueDBGrid1_Error(object sender,
      C1.Win.C1TrueDBGrid.ErrorEventArgs e)
      {
          if (c1TrueDBGrid1.Columns[c1TrueDBGrid1.Col].DataField ==
      "CategoryID")
          {
              e.Handled = true;
              MessageBox.Show("Your User Friendly Message");
          }
          else
          {
              e.Handled = false;
              MessageBox.Show("Enter a string");
          }
      }