DataGridView.NotifyCurrentCellDirty(Boolean) 方法
定义
通知 DataGridView 当前单元格有未提交的更改。Notifies the DataGridView that the current cell has uncommitted changes.
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
。true
to indicate the cell has uncommitted changes; otherwise, false
.
示例
下面的代码示例演示如何在自定义单元格方案中使用此方法。The following code example illustrates the use of this method in a custom cell scenario. 在此示例中,派生自 @no__t 类的 @no__t 0 实现替代了 OnValueChanged 方法,并使用了 NotifyCurrentCellDirty 方法指示对 @no__t 控件的更改。In the example, an IDataGridViewEditingControl implementation derived from the DateTimePicker class overrides the OnValueChanged method and uses the NotifyCurrentCellDirty method to indicate a change to the DataGridView control.
此示例摘自 [How 中显示的一个更大的示例:Windows 窗体 DataGridView 单元格中的主机控件 @ no__t-0。This example is part of a larger example shown in 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。This method can be used to allow custom cell types to notify the DataGridView when they have uncommitted changes.