I'm having troubles with what I'm trying to do in VB.NET. This is a datagridview where the program should check if a character is allowed to be written or not in some columns (not all of them), I use the C event to know the column where the cursor is, and the E event to know which key is pressed. All that at the same time.
I've done this code, I know it's wrong, and VB shows me this msg:
"Method 'Private Sub dgw_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs, c As System.Windows.Forms.DataGridViewCellEventArgs)' cannot handle event 'Public Event KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs)' because they do not have a compatible signature."
here is my code:
Private Sub dgw_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs, ByVal c As System.Windows.Forms.DataGridViewCellEventHandler) Handles dgw.KeyPress, dgw.Celledit
If e.ColumnIndex = 2 Or e.ColumnIndex = 3 Or e.ColumnIndex = 4 Or e.ColumnIndex = 5 Then
If (Not Char.IsNumber(e.KeyChar) And e.KeyChar <> Microsoft.VisualBasic.ChrW(8) And e.KeyChar <> Microsoft.VisualBasic.ChrW(58)) Then
e.Handled = True End If End If end sub
what's wrong?? thanks!!
Aucun commentaire:
Enregistrer un commentaire