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但要按两次回车键才移动到下一行,怎么解决?

解决方案 »

  1.   

    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中调试通过!
      

  2.   

    但要按两次回车键才移动到下一行,我的要求是按一次回车键(像Excel一样),怎么解决?我用的是vsflexgrid8.0
      

  3.   

    没进入表格编辑的时候,我觉得你的代码没有任何问题,何须两次呢?进入表格编辑了.通常按一次完成编辑,再按一次响应你的代码本来就是合理的一定要的话,在CellChanged事件里处理
      

  4.   

    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 SubPrivate 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全部分给我.
      

  5.   

    或者选择状态:
    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 SubPrivate 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
      

  6.   

    下面是我自己解决的方法:
    '-------按回车键移到下一行-----------------Private Sub VSFlexGrid1_AfterEdit(ByVal Row As Long, ByVal Col As Long)
        VSFlexGrid1.Row = VSFlexGrid1.Row + 1 '按回车键移动到下一行
    'End Sub
    '-------------------------------------------