DataGridView.CellValidated 事件

定义

单元格完成验证时发生。

public:
 event System::Windows::Forms::DataGridViewCellEventHandler ^ CellValidated;
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 属性。 在此示例中, CellValidating 如果用户在单元格中输入无效的数据,事件将设置 ErrorText 。 此示例是 事件中提供的更大示例的 SelectionChanged 一部分。

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

注解

处理此事件对于单元格值的验证后处理非常有用。

有关如何处理事件的详细信息,请参阅 处理和引发事件

适用于

另请参阅