【发布时间】:2023-03-13 21:56:01
【问题描述】:
我有一个关于数据网格的问题我有一个数据网格视图,并且希望某些单元格仅限于使用数字,而其他单元格则可以接受用户想要的任何文本。我想出的想法是使用数据网格单元格值更改事件,它检查指定的单元格以查看它是否包含数值,如果是,则继续显示消息框并重新选择不正确的单元格,直到它包含我的示例中的数字只是移动到另一个单元格我该如何解决这个问题?
MessageBox.Show("Changed")
Dim HVAL As String
HVAL = DataGridView2.Rows(2).Cells(1).Value
If IsNumeric(HVAL) Then
MsgBox("is number, do nothing")
Else
MsgBox("is other than number")
DataGridView2.Rows(2).Cells(1).Selected = True
DataGridView2.Rows(2).Cells(1).Style.SelectionBackColor = Color.Crimson
End If
End Sub
【问题讨论】:
标签: vb.net datagridview isnumeric