Occurs when a cell's error text is needed.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The event occurs only when the DataGridView control DataSource property is set or its VirtualMode property is true. Handling the event is useful when you want to determine the error for a cell depending on its value or state.
When you handle the event and specify error text in the handler, an error glyph appears in the cell unless the ShowCellErrors property is set to false or the cell is in edit mode. When the user moves the mouse pointer over the error glyph, the error text appears in a ToolTip.
The event also occurs whenever the value of the DataGridViewCell.ErrorText property is retrieved.
You can use the DataGridViewCellEventArgs.RowIndex and ColumnIndex property to determine the state or value of a cell, and use this information to change or modify the DataGridViewCellErrorTextNeededEventArgs.ErrorText property. This property is initialized with the value of the cell ErrorText property, which the event value overrides.
Handle the event when working with large amounts of data to avoid the performance penalties of setting the cell ErrorText value for multiple cells. For more information, see Best Practices for Scaling the Windows Forms DataGridView Control.
For more information about handling events, see Consuming Events.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2