VB listview 选中行的代码怎么确定
就是我想取得选中行的第一行列是第几行第几列,最后一行列是第几行第几列DimiAsLong,jAsLong,sAsStrings=""Fori=1ToLV1.ColumnH...
就是我想取得选中行的第一行列是第几行第几列,最后一行列是第几行第几列
Dim i As Long, j As Long, s As String
s = ""
For i = 1 To LV1.ColumnHeaders.Count
s = s + LV1.ColumnHeaders.Item(i).Text + vbTab
Next i
s = s + vbCrLf
For i = lv1.SelectedItem.Index To LV1.SelectedItem.Index +???
s = s + CStr(i) + vbTab
For j = 1 To LV1.ColumnHeaders.Count - 1
s = s + LV1.ListItems.Item(i).SubItems(j) + vbTab
Next j
s = s + vbCrLf
Next i
Clipboard.Clear
Clipboard.SetText s
上面的???是我想获取的选中了多少行的代码。。(最好也有获取了多少列。。。)
求代码求代码 展开
Dim i As Long, j As Long, s As String
s = ""
For i = 1 To LV1.ColumnHeaders.Count
s = s + LV1.ColumnHeaders.Item(i).Text + vbTab
Next i
s = s + vbCrLf
For i = lv1.SelectedItem.Index To LV1.SelectedItem.Index +???
s = s + CStr(i) + vbTab
For j = 1 To LV1.ColumnHeaders.Count - 1
s = s + LV1.ListItems.Item(i).SubItems(j) + vbTab
Next j
s = s + vbCrLf
Next i
Clipboard.Clear
Clipboard.SetText s
上面的???是我想获取的选中了多少行的代码。。(最好也有获取了多少列。。。)
求代码求代码 展开
3个回答
2011-09-06
展开全部
listview应该实现不了的,它只能整行选择,可以用mshflexgrid控件:
Private Sub Command1_Click()
Dim i As Long, j As Long, s As String
s = ""
With Me.Grid
For i = .Col To .ColSel
s = s + .TextMatrix(0, i) + vbTab
Next i
s = s + vbCrLf
For i = .Row To .RowSel
s = s + CStr(i) & "-" + vbTab
For j = .Col To .ColSel
s = s + .TextMatrix(i, j) + vbTab
Next j
s = s + vbCrLf
Next i
End With
Clipboard.Clear
Clipboard.SetText s
End Sub
Private Sub Command1_Click()
Dim i As Long, j As Long, s As String
s = ""
With Me.Grid
For i = .Col To .ColSel
s = s + .TextMatrix(0, i) + vbTab
Next i
s = s + vbCrLf
For i = .Row To .RowSel
s = s + CStr(i) & "-" + vbTab
For j = .Col To .ColSel
s = s + .TextMatrix(i, j) + vbTab
Next j
s = s + vbCrLf
Next i
End With
Clipboard.Clear
Clipboard.SetText s
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
按ListView1.Index来删除对应ACC 个人觉得不大好用~还不如用SQL语句来删除
Dim c As Long
c = fomr1.ListView1.SelectedItem.Index
fomr1.ListView1.ListItems.Remove (fomr1.ListView1.SelectedItem.Index)
fomr1.rsData.MoveFirst
Do While Not fomr1.rsData.EOF
If fomr1.rsData.Fields(0).Value = c Then
fomr1.rsData.Delete
End If
fomr1.rsData.MoveNext
Loop
If fomr1.rsData.RecordCount = 0 Then
Exit Sub
End If
If fomr1.ListView1.SelectedItem.Index <> Str$(fomr1.rsData.RecordCount + 1) Then
fomr1.rsData.MoveFirst
Do While s < fomr1.rsData.RecordCount
fomr1.rsData.Edit
fomr1.rsData.Fields(0).Value = t
fomr1.rsData.Update
t = t + 1
s = s + 1
fomr1.rsData.MoveNext
Loop
s = 0
t = 1
End If
fomr1.ListView1.ListItems.Clear
End Sub
End Sub
用SQL语句
Public Sub Command13_Click()
Dim sql As String
sql = "delete * from 表 where 字段 = 值"
db.Execute (sql) 执行QSL语句
ListView3.ListItems.Clear
End Sub
Dim c As Long
c = fomr1.ListView1.SelectedItem.Index
fomr1.ListView1.ListItems.Remove (fomr1.ListView1.SelectedItem.Index)
fomr1.rsData.MoveFirst
Do While Not fomr1.rsData.EOF
If fomr1.rsData.Fields(0).Value = c Then
fomr1.rsData.Delete
End If
fomr1.rsData.MoveNext
Loop
If fomr1.rsData.RecordCount = 0 Then
Exit Sub
End If
If fomr1.ListView1.SelectedItem.Index <> Str$(fomr1.rsData.RecordCount + 1) Then
fomr1.rsData.MoveFirst
Do While s < fomr1.rsData.RecordCount
fomr1.rsData.Edit
fomr1.rsData.Fields(0).Value = t
fomr1.rsData.Update
t = t + 1
s = s + 1
fomr1.rsData.MoveNext
Loop
s = 0
t = 1
End If
fomr1.ListView1.ListItems.Clear
End Sub
End Sub
用SQL语句
Public Sub Command13_Click()
Dim sql As String
sql = "delete * from 表 where 字段 = 值"
db.Execute (sql) 执行QSL语句
ListView3.ListItems.Clear
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
只能选第一列吧?
如同户口薄上一个家庭只有一个户主
如同户口薄上一个家庭只有一个户主
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询