Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ErrorText Property

DataGridViewCell.ErrorText Property

Gets or sets the text describing an error condition associated with the cell.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

[<BrowsableAttribute(false)>]
member ErrorText : string with get, set

Property Value

Type: System.String
The text that describes an error condition associated with the cell.

Typically, the ErrorText property is used when handling the CellValidating event of the DataGridView. If the cell's value fails some validation criteria, set the ErrorText property and cancel the commit operation by setting the Cancel property of the DataGridViewCellValidatingEventArgs to true. The text you specify is then displayed by the DataGridView, and the user is prompted to fix the error in the cell's data.

When the VirtualMode property of the DataGridView is true, you can provide error text for rows and cells using the RowErrorTextNeeded and CellErrorTextNeeded events.

When you assign a different ErrorText string to a cell, the CellErrorTextChanged event of the DataGridView control is raised.

Starting with the .NET Framework 4.5.2, resizing of the error icon is determined by the system DPI setting when the app.config file contains the following entry:

<appSettings>
  <add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
</appSettings>

The following code example demonstrates how to use this property when handling error conditions in an unbound DataGridView. The AnnotateCell method sets an error message string to the ErrorText property.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft