vb datagrid同时删除几行的问题,附代码,求帮助啊,小弟跪谢了
Private Sub Command_3_Click()
Dim intYesNo
Frame_add.Visible = False
DataGrid1.AllowDelete = True
If DataGrid1.SelBookmarks.Count = 0 Then
MsgBox "请选择一条记录以供操作!", vbOKOnly + vbExclamation, "注意!"
Exit Sub
ElseIf CZLX = 1 Then
Adodc1.RecordSource = "select *from tb_BasicInformation"
Adodc1.Refresh
intYesNo = MsgBox("确实要删除这条参数吗?", vbYesNo + vbExclamation, "注意!")
If intYesNo = vbYes Then
Dim varBmk As Variant
For Each varBmk In DataGrid1.SelBookmarks
Adodc1.Recordset.Bookmark = varBmk
Adodc1.Recordset.Delete
Adodc1.Recordset.UpdateBatch
Next
End If
DataGrid1.Refresh
Adodc1.RecordSource = "select *from tb_BasicInformation"
Label_Num.Caption = Adodc1.Recordset.RecordCount vb?datagrid?同时删除几行
[解决办法]
dim BK as variant
With TxGrid
For i = .SelBookmarks.Count - 1 To 0 Step -1
BK = .SelBookmarks(i)
rsData.Bookmark = BK
rsData.Delete
Next
End With
[解决办法]
1楼应该是正确的啊,测试了可以……
Dim vI As Integer
For vI = DataGrid1.SelBookmarks.Count - 1 To 0 Step -1
Adodc1.Recordset.Bookmark = DataGrid1.SelBookmarks(vI)
Adodc1.Recordset.Delete
Next