关于VB.NET Datagridview光标定位问题!急!求帮忙

an7306911 2014-02-28 03:05:27
我对DataGridView的cell进行了输入合法的检查, 只能输入数字,输入非法弹出对话框,点击确定后想让当前的cell 获取焦点。 代码如下:
For i As Integer = 1 To Len(tempStr)
Dim ch1 As String = Mid(tempStr, i, 1) '取得输入的字符串
If ch1 >= "0" AndAlso ch1 <= "9" Then
tempBool = False
ElseIf ch1 = "-" Then
tempBool1 = False
Else
tempMsg = "Only numbers or ' - ' allow input!"
Dim m_Sysmsg As New SysMsg
m_Sysmsg.ShowDialog()
Me.DataGrid_Score.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = String.Empty
Me.DataGrid_Score.ClearSelection()
Me.DataGrid_Score.Rows(e.RowIndex).Cells(e.ColumnIndex).Selected = True
Me.DataGrid_Score.currentcells = Me.DataGrid_Score.Rows(e.RowIndex).Cells(e.ColumnIndex)
Return
End If
Next
...全文
189 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
an7306911 2014-02-28
  • 打赏
  • 举报
回复
但是焦点回不去,提示非法点击确定后,直接输入的话,数字会在别个cells里,求大神帮忙解决下,代码所在事件是 cell_endedit

16,553

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧