【发布时间】:2014-07-09 08:13:48
【问题描述】:
我正在使用 DatagridView 工具。在这里,我正在对列进行手动输入并将其直接保存到数据库中。我有 5 列,其中 3 列是字母数字列,2 列是数字列。
我已使用 EditingControlShowing 事件中的处理程序为数值列设置条件。
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
此条件正常工作。但问题是,这种情况适用于所有列。我只想让它在指定的列上工作。
请帮我解决这个问题。
提前致谢。
【问题讨论】:
标签: vb.net winforms c#-4.0 datagridview