datagrid中怎么样才能删除选种的一条记录

解决方案 »

  1.   

    Option ExplicitPrivate Sub Command1_Click()
    DataGrid1.AllowDelete = True
    Adodc1.Recordset.Delete adAffectCurrent
    End Sub
      

  2.   

    批量删除datagrid中的记录(用shift多选后)
    其中rs为一个recordset,是datagrid的datasourceDim varBmk As Variant
        
        With Rs
        For Each varBmk In gridBook.SelBooks    '当DataGrid某一行处于选中状态时
            .Book = varBmk
            .Delete
            
            If .EOF Then
                .MoveLast
             Else
                .MoveNext
             End If
        Next varBmk
        End With
      

  3.   

    with rs
       .delete
       if .eof then
          .movelast
       else
          .movenext
       end if
    end with