如何控制DataGridView 单元格内小数点后输入两位小数只是第一位有“-”号
我现在只控制了输入数字,小数点和"-"号 ,想比如我输了一个9.89当我再输一个数字6时就输不了~怎么实现呢,请各位高手帮小弟解决下,贴下代码,非常感谢!!!
Private Sub Cells_KeyPress(ByVal sender As System.Object, ByVal e As Windows.Forms.KeyPressEventArgs)
If e.KeyChar <> Chr(8) And e.KeyChar <> Chr(13) And e.KeyChar <> Chr(46) And e.KeyChar <> Chr(45) And (e.KeyChar < Chr(48) Or e.KeyChar > Chr(57)) Then
Beep()
Beep()
e.KeyChar = Chr(0)
Else
endif
sub
[解决办法]
Cells_KeyPress事件里,取得当前Cell里的文字长度,如果>3,那么e.handled = true