我不确定十分了解您的意思,您是否是要清空正在编辑的值?
请尝试以下代码,确定是否满足您的需求。
C#- void gcMultiRow_CellValidating(object sender, CellValidatingEventArgs e)
- {
- if (IsInvalidValue(e.FormattedValue)) // 值不合法。
- {
- e.Cancel = true;
- IEditingControl editingControl = gcMultiRow.EditingControl as IEditingControl;
- if (editingControl != null)
- {
- editingControl.FormattedValue = null;
- }
- }
- }
复制代码 VB- Private Sub gcMultiRow_CellValidating(sender As Object, e As CellValidatingEventArgs) Handles gcMultiRow.CellValidating
- If IsInvalidValue(e.FormattedValue) Then
- ' 值不合法。
- e.Cancel = True
- Dim editingControl As IEditingControl = TryCast(gcMultiRow.EditingControl, IEditingControl)
- If editingControl IsNot Nothing Then
- editingControl.FormattedValue = Nothing
- End If
- End If
- End Sub
复制代码 |