Built in Error Provider Support in Windows Forms GridDataBoundGrid

26 Apr 20212 minutes to read

Essential Grid for Windows Forms now provides a built-in error provider for error alerts. This feature enables you to display an error icon in a specific cell and row header when incorrect data is entered in a cell. This also enables you to specify the error conditions.

Use Case Scenarios

This feature is useful when you want to set only numeric values to be entered in a cell.

PROPERTIES DESCRIPTION TYPE DATA TYPE
ShowErrorIcon Specifies whether to show error icon. NA Boolean
ShowRowHeaderErrorIcon Specifies whether to show error icon in the row header. NA Boolean
ShowErrorMessageBox Specifies whether to show error message box. NA Boolean
ValidationErrorText Specifies the text to be displayed in the error message box. NA Boolean
METHOD DESCRIPTION PARAMETERS TYPE RETURN TYPE
SetError() Method (string) Method String

A sample of this feature is available in the following location:

GridDataBoundGrid

<Install Location>\Syncfusion\EssentialStudio[Version Number]\Windows\GridDataBound.Windows\Samples\Appearance\Error Provider Demo

<Install Location>\Syncfusion\EssentialStudio[Version Number]\Windows\Grid.Grouping.Windows\Samples\Styling and Formatting\Error Provider Demo

<Install Location>\Syncfusion\EssentialStudio[Version Number]\Windows\Grid.Windows\Samples\Grid Layout\Error Provider Demo

Enabling Error Alert

You can show an error icon or error message box as an alert for incorrect data.

Displaying error icon

You can show the error icon in the cell and row header using the ShowErrorIcon and the ShowRowHeaderErrorIcon properties respectively.

To show the error icon in the cell, set ShowErrorIcon property to True. By default this will be set to True. To show the error icon in the row header, set ShowRowHeaderErrorIcon property to True. By default this will be set to False. You can display the error icon in the cell as well as a row header if needed.

The following code illustrates how to display the error icon on both the cell as well as the row header:

this.gridDataBoundGrid1.CurrentCell.ShowErrorIcon = true;
this.gridDataBoundGrid1.ShowRowHeaderErrorIcon = true;
Me.gridDataBoundGrid1.CurrentCell.ShowErrorIcon = True
Me.gridDataBoundGrid1.ShowRowHeaderErrorIcon = True

Built-in-Error-Provider-Support_img1

Displaying error message box

You can show an error dialog using ShowErrorMessageBox property and specify the content to be displayed using the ValidationErrorText property.

The following code illustrates this:

this.gridDataBoundGrid1.CurrentCell.ShowErrorMessageBox= false;
this.gridDataBoundGrid1.CurrentCell.ValidationErrorText = "this is the text";
Me.gridDataBoundGrid1.CurrentCell.ShowErrorMessageBox= False
Me.gridDataBoundGrid1.CurrentCell.ValidationErrorText = "this is the text"

Windows Forms Grid Image2

Specifying Error Content

You can specify error conditions for individual cells using SetError() method of GridCurrentCell.

The following code illustrates this:

this.gridDataBoundGrid1.CurrentCell.SetError("Please enter valid number");
Me.gridDataBoundGrid1.CurrentCell.SetError("Please enter valid number")