共用方式為


DataGridView.NotifyCurrentCellDirty(Boolean) 方法

定義

通知 DataGridView 目前的儲存格有未認可的變更。

public:
 virtual void NotifyCurrentCellDirty(bool dirty);
public virtual void NotifyCurrentCellDirty (bool dirty);
abstract member NotifyCurrentCellDirty : bool -> unit
override this.NotifyCurrentCellDirty : bool -> unit
Public Overridable Sub NotifyCurrentCellDirty (dirty As Boolean)

參數

dirty
Boolean

true 表示儲存格有未經認可的變更;否則為 false

範例

下列程式碼範例說明在自訂儲存格案例中使用此方法。 在此範例中, IDataGridViewEditingControl 衍生自 類別的 DateTimePicker 實作會 OnValueChanged 覆寫 方法,並使用 NotifyCurrentCellDirty 方法來指出控制項的 DataGridView 變更。

此範例是How to: Host Controls in Windows Forms DataGridView Cells中顯示之較大範例的一部分。

protected override void OnValueChanged(EventArgs eventargs)
{
    // Notify the DataGridView that the contents of the cell
    // have changed.
    valueChanged = true;
    this.EditingControlDataGridView.NotifyCurrentCellDirty(true);
    base.OnValueChanged(eventargs);
}
Protected Overrides Sub OnValueChanged(ByVal eventargs As EventArgs)

    ' Notify the DataGridView that the contents of the cell have changed.
    valueIsChanged = True
    Me.EditingControlDataGridView.NotifyCurrentCellDirty(True)
    MyBase.OnValueChanged(eventargs)

End Sub

備註

這個方法可用來允許自訂資料格類型在未認可的變更時通知 DataGridView

適用於

另請參閱