根据您提供的Demo,使用ValidateEdit事件比较容易处理值得校验。
不合法值弹出对话框,并且停留在该单元格。
代码参考:
- Private Sub C1FlexGrid1_ValidateEdit(sender As Object, e As C1.Win.C1FlexGrid.ValidateEditEventArgs) Handles C1FlexGrid1.ValidateEdit
- If (e.Col = 1) Then
- Try
- Dim value As Integer = Integer.Parse(C1FlexGrid1.Editor.Text)
- If (value = 0) Then
- Return
- End If
- Catch ex As Exception
- End Try
- MsgBox("输入不正确,请重新输入!", MsgBoxStyle.Critical)
- e.Cancel = True
- End If
- End Sub
复制代码 |