C1TrueDBGrid displays a message for any errors that occur when building a project. You must switch off the internal error handling.
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.
Private Sub C1TrueDBGrid1_Error(ByVal sender As Object, ByVal e As C1.Win.C1TrueDBGrid.ErrorEventArgs) Handles C1TrueDBGrid1.Error
e.Handled = True
End Sub
· C#
private void c1TrueDBGrid1_Error(object sender, C1.Win.C1TrueDBGrid.ErrorEventArgs e)
{
e.Handled = true;
}
· Delphi
Procedure TForm1.C1TrueDBGrid1_Error(sender: object; e: C1.Win.C1TrueDBGrid.ErrorEventArgs);
begin
e.Handled := True;
end;
2. You can then add your own error-handling code. For example:
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
· C#
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");
}
}
· Delphi
procedure TForm1.c1TrueDBGrid1_Error(sender: object; e:
C1.Win.C1TrueDBGrid.ErrorEventArgs);
begin
if (c1TrueDBGrid1.Columns[c1TrueDBGrid1.Col].DataField = 'CategoryID')
then
begin
e.Handled := true;
MessageBox.Show('Your User Friendly Message');
end
else
begin
e.Handled := false;
MessageBox.Show('Enter a string');
end;
end;
Send comments about this topic to ComponentOne. Copyright © ComponentOne LLC. All rights reserved. |