DataGridView.CellValidated 事件


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

 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 


下面的代码示例演示如何使用 @no__t 0 事件来清除 @no__t 1 属性。The following code example demonstrates how to use the CellValidated event to clear out the ErrorText property. 在此示例中,如果用户输入的数据对单元格无效,@no__t 0 事件会将 @no__t 设置为-1。In 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.