Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)End Sub
里面记录行号和列号,然后使用

解决方案 »

  1.   

    Private Sub DataGridp_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
       MsgBox LastRow
       MsgBox LastCol
    End SubPrivate Sub DataGridp_SelChange(Cancel As Integer)
      MsgBox Cancel
    End Sub
    但是均返回不到正确的数,lastrow返回的是51x,好象也没什么规律,lastcol返回0-5
    后面一个返回的也不对!
      

  2.   

    '直接用 VBA.MsgBox adoRecordset.Fields.Item(0).Value
    '注意这个属性: DataGrid1.MarqueeStyle 
    Option Explicit
    Dim bIsRow As Boolean
    Dim adoRecordset As New ADODB.Recordset
    Dim adoConnection As New ADODB.Connection
    Private Sub Form_Load()
    '注意这个属性:
    DataGrid1.MarqueeStyle = dbgHighlightRow
    '=======================================
    adoConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\NWind97.mdb;Persist Security Info=False"
    Set adoRecordset.ActiveConnection = adoConnection
    adoRecordset.Properties("IRowsetIdentity").Value = True
    adoRecordset.Open "SELECT * FROM 产品", , adOpenKeyset
    Set DataGrid1.DataSource = adoRecordset
    End Sub
    Private Sub DataGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    bIsRow = (DataGrid1.RowContaining(Y) >= 0)
    End Sub
    Private Sub DataGrid1_DblClick()
    If Not adoRecordset.BOF And Not adoRecordset.EOF And bIsRow Then
    VBA.MsgBox adoRecordset.Fields.Item(0).Value
    End If
    End Sub
      

  3.   

    可以了,我马上给分!
    这个VBA是什么意思呢?
    VBA.MsgBox adoRecordset.Fields.Item(0).Value
    我直接用MSGBOX也可以!
      

  4.   

    如果你想要取得DataGrid中当前选中行的记录内容 ,可以直接访问该DataGrid绑定的RecordSet,该Rs的游标是与DataGrid的选中行同步移动的。
    Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
        MsgBox Rs("FiledName")
    End Sub
      

  5.   

    VBA就是Visual Basic Application的简称,是工程中的一个默认类,我们使用的大多数函数都是它提供的哦
      

  6.   

    说的再明白一点,就是MSVBVM60.DLL,呵呵,这个类库你敢不用!!!??