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.

適用於

另請參閱