I am working on with DatagridView tool. Here I am doing a manual entry on columns and save it directly to database. I have 5 columns out of which 3 are alphanumeric and 2 are numeric columns.
I have set condition to for numeric columns using handlers in EditingControlShowing event.
If grdLedgerDetails.CurrentCell.ColumnIndex = 4 Then
AddHandler CType(e.Control, TextBox).KeyPress, AddressOf TextBox_keyPress
ElseIf grdLedgerDetails.CurrentCell.ColumnIndex = 5 Then
AddHandler CType(e.Control, TextBox).KeyPress, AddressOf TextBox_keyPress
End If
Private Sub TextBox_keyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
If Char.IsDigit(CChar(CStr(e.KeyChar))) = False Then e.Handled = True
End Sub
This condition works properly. But the problem is that, this condition works on all columns. I just want it to be worked on specified column.
Please help me out from this.
Thanks in advance.