Articles in this section
Category / Section

How to know programmatically if the grid has any error in WPF GridDataControl?

4 mins read

WPF GridDataControl enables you to get the error info for each cell using QueryCellInfo event. The HasErrorInfo property indicates you whether the particular cell has any error information or not. When the cell has any error you can use ErrorInfo property to get the error information of that particular cell. Refer the following code snippet.

C#

dataGrid.Model.QueryCellInfo += new GridQueryCellInfoEventHandler(OnQueryCellInfo);
void OnQueryCellInfo(object sender, GridQueryCellInfoEventArgs e) //to get error info 
{
    if (e.Style.HasErrorInfo)
        Console.WriteLine(e.Style.ErrorInfo);
    else
        Console.WriteLine("No errors");
}

 

Here, you can check whether the cell has any error using “HasErrorInfo”. When there is any error, an ErrorInfo displays in the output window, else “No errors” displays in the output window.

Other properties related to ErrorInfo are given as follows.

 

Property Name

Return Type

Description

HasError

boolean

Checks whether any Error has been initialized for the current object.

Error

string

Contains error information when a text could not be converted to the type specified with CellValueType.

HasErrorAlertText

boolean

Checks whether the current object has any error alert text.

ErrorAlertText

string

Gets or sets the error alert text. Holds the error alert text when importing the excel file to grid.

HasErrorAlertTitle

boolean

Checks whether the current object has any error alert title.

ErrorAlertTitle

string

Gets or sets the error alert title. Holds the error alert title while importing the excel file to grid.


Conclusion

I hope you enjoyed learning about how to know programmatically if the grid has any error in WPF GridDataControl.


You can refer to our WPF GridDataControl feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.
You can also explore our WPF GridDataControl example
to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!






Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied