vsflexgrid控件编辑数据时,按回车键移到下一行,如何实现,急等!!!

qqyong 2005-05-02 07:11:57
vsflexgrid控件编辑数据时,按回车键移到下一行,如何实现,急等!!!

我的代码如下:

Private Sub VSFlexGrid1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
With VSFlexGrid1
.Row = .Row + 1
End With
KeyAscii = 0
End If
End Sub

但要按两次回车键才移动到下一行,怎么解决?
...全文
382 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
I_Love_VB2003 2005-05-08
  • 打赏
  • 举报
回复
或者选择状态:
Private Sub VSFlexGrid1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
VSFlexGrid1.Select VSFlexGrid1.Row + 1, VSFlexGrid1.Col
VSFlexGrid1.ShowCell VSFlexGrid1.Row + 1, VSFlexGrid1.Col
KeyAscii = 0
End If
End Sub

Private Sub VSFlexGrid1_KeyPressEdit(ByVal Row As Long, ByVal Col As Long, KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
VSFlexGrid1.Select Row + 1, Col
VSFlexGrid1.ShowCell Row + 1, Col
End If
End Sub
I_Love_VB2003 2005-05-08
  • 打赏
  • 举报
回复
Private Sub VSFlexGrid1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
VSFlexGrid1.Select VSFlexGrid1.Row + 1, VSFlexGrid1.Col
VSFlexGrid1.ShowCell VSFlexGrid1.Row + 1, VSFlexGrid1.Col
End If
End Sub

Private Sub VSFlexGrid1_KeyPressEdit(ByVal Row As Long, ByVal Col As Long, KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
VSFlexGrid1.Select Row + 1, Col
VSFlexGrid1.ShowCell Row + 1, Col
SendKeys "{F2}"
End If
End Sub

全部分给我.
sektor 2005-05-08
  • 打赏
  • 举报
回复
没进入表格编辑的时候,我觉得你的代码没有任何问题,何须两次呢?

进入表格编辑了.通常按一次完成编辑,再按一次响应你的代码本来就是合理的

一定要的话,在CellChanged事件里处理
CPLiu 2005-05-08
  • 打赏
  • 举报
回复
关注,好象捕获回车比较困难
qqyong 2005-05-08
  • 打赏
  • 举报
回复
高手都不来吗?
qqyong 2005-05-08
  • 打赏
  • 举报
回复
下面是我自己解决的方法:
'-------按回车键移到下一行-----------------

Private Sub VSFlexGrid1_AfterEdit(ByVal Row As Long, ByVal Col As Long)
VSFlexGrid1.Row = VSFlexGrid1.Row + 1 '按回车键移动到下一行
'End Sub
'-------------------------------------------
qqyong 2005-05-07
  • 打赏
  • 举报
回复
但要按两次回车键才移动到下一行,我的要求是按一次回车键(像Excel一样),怎么解决?

我用的是vsflexgrid8.0
cosio 2005-05-04
  • 打赏
  • 举报
回复
Private Sub VSFlexGrid1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
With VSFlexGrid1
.Row = .Row + 1
End With
KeyAscii = 0
End If
End Sub
上面的代码在vsflexgrid6.0中调试通过!
qqyong 2005-05-04
  • 打赏
  • 举报
回复
没用
VBDN 2005-05-02
  • 打赏
  • 举报
回复
将KeyDown事件中处理试试!

7,764

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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