DataGridView.NotifyCurrentCellDirty(Boolean) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
通知 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 窗体 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 它们。