datagrid 与记录集绑定想使用RowColChange事件出现问题:当在datagrid 上用方向键时,当移向未显示部分的行时,RowColChange事件没被触发。可直接用鼠标在datagrid 点击时没问题,每点必触发RowColChange事件。

解决方案 »

  1.   

    Option ExplicitPublic Rs As New ADODB.Recordset
    Public Conn As New ADODB.ConnectionPublic Sub Make_Connection()
        Dim strConn As String
        strConn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=pubs;Data Source=ANYA"
        Conn.CursorLocation = adUseClient
        Conn.Open strConn
        
        If Rs.State <> adStateClosed Then Rs.Close
        Rs.Open "Select * from jobs", Conn, adOpenStatic, adLockOptimistic
        
        Set Me.DataGrid1.DataSource = Rs
    End SubPrivate Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
      Debug.Print "Change"
    End SubPrivate Sub Form_Load()
       Call Make_Connection
    End Sub
    有问题吗?我测试完全没问题,完全触发了,对了我是SP6