在DataGrid里按回车键不能自动移动到下一个,有办法解决吗?

解决方案 »

  1.   

    ms社區有篇是按tab可以移動﹐應該可以﹐但是沒有嘗試。
    你是要加數據時候移動還是在瀏覽數據時候﹐移動到下一條?
      

  2.   


    Private Sub DataGrid1_KeyPress(KeyAscii As Integer)
            Dim I As Long
            If KeyAscii = 13 Then
               I = DataGrid1.Row()
               DataGrid1.Row = I + 1
            End If
    End Sub
      

  3.   

    更正一下,忘记了一句话:On Error Resume Next
    Private Sub DataGrid1_KeyPress(KeyAscii As Integer)
            Dim I As Long
            
            On Error Resume Next
            
            If KeyAscii = 13 Then
               I = DataGrid1.Row()
               DataGrid1.Row = I + 1
            End If
    End Sub
      

  4.   

    http://expert.csdn.net/Expert/topic/2393/2393178.xml?temp=5.239505E-02
      

  5.   

    Private Sub DataGrid1_KeyPress(KeyAscii As Integer)
    On Error Resume Next
            Dim row As Long, col As Long
            row = DataGrid1.row
            col = DataGrid1.col
          If KeyAscii = 13 Then
         If DataGrid1.col = DataGrid1.Columns.Count - 1 Then
    DataGrid1.row = row + 1
    DataGrid1.col = 0
    Else
    DataGrid1.col = col + 1
    End If
    End If
    End Sub