问题解决了,发出来共享一下.
Public EditCell As DataGridViewTextBoxEditingControl
Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
EditCell = CType(e.Control, DataGridViewTextBoxEditingControl)
EditCell.SelectAll()
AddHandler EditCell.KeyPress, AddressOf Cells_KeyPress
End Sub
Private Sub Cells_KeyPress(ByVal sender As System.Object, ByVal e As KeyPressEventArgs)
If e.KeyChar <> Chr(8) And e.KeyChar <> Chr(13) And (e.KeyChar < Chr(48) Or e.KeyChar > Chr(57)) Then
Beep()
Beep()
e.KeyChar = Chr(0)
End If
End Sub
[此贴子已经被作者于2007-7-18 16:43:05编辑过]