DataGridView.CellValidated 事件

定义

单元格完成验证时发生。Occurs after the cell has finished validating.

public:
 event System::Windows::Forms::DataGridViewCellEventHandler ^ CellValidated;
public event System.Windows.Forms.DataGridViewCellEventHandler CellValidated;
member this.CellValidated : System.Windows.Forms.DataGridViewCellEventHandler 
Public Custom Event CellValidated As DataGridViewCellEventHandler 

示例

下面的代码示例演示如何使用 CellValidated 事件来清除 ErrorText 属性。The following code example demonstrates how to use the CellValidated event to clear out the ErrorText property. 在此示例中,如果用户输入的数据对单元格无效,则 CellValidating 事件将设置 ErrorTextIn this example, the CellValidating event sets the ErrorText if the user enters data that is not valid into a cell. 此示例是 SelectionChanged 事件中提供的更大示例的一部分。This example is part of a larger example available in the SelectionChanged event.

private void DataGridView1_CellValidated(object sender,
    DataGridViewCellEventArgs e)
{
    // Clear any error messages that may have been set in cell validation.
    DataGridView1.Rows[e.RowIndex].ErrorText = null;
}
Private Sub CellValidated(ByVal sender As Object, _
    ByVal e As DataGridViewCellEventArgs) _
    Handles DataGridView1.CellValidated

    ' Clear any error messages that may have been set in cell validation.
    DataGridView1.Rows(e.RowIndex).ErrorText = Nothing
End Sub

注解

处理此事件对于单元格值的验证后处理非常有用。Handling this event is useful for post-validation processing of the cell value.

有关如何处理事件的详细信息,请参阅处理和引发事件For more information about how to handle events, see Handling and Raising Events.

适用于

另请参阅