关于ListView控件的问题:如何批量移动勾选的条目?请大家帮帮我,谢谢你们了!
我现在将数据读入ListView中,并且允许复选,我想将我所选中的条目批量显示在TEXT控件中(单个的我已经实现,但是无论我选择多少,总是只显示最后一条,而不是我所有选中的)。这个问题困扰我很久了,请大家帮帮我,小弟初来,还没弄明白积分……请大家不要嫌弃,谢谢了。 --------------------编程问答--------------------
'窗体中放一个TextBox,将lock属性设置为true,multiline设置为true,一个ListView,一个command按钮
Private Sub Command1_Click()
Dim i As Long
With Me.Text1
.Text = vbNullString
End With
With Me.ListView1.ListItems
For i = 1 To .Count
If .Item(i).Checked = True Then
If Len(Me.Text1.Text) <> 0 Then
Me.Text1.Text = Me.Text1.Text & vbCrLf & .Item(i).Text & "--" & .Item(i).SubItems(1) & "--" & .Item(i).SubItems(2)
Else
Me.Text1.Text = .Item(i).Text & "--" & .Item(i).SubItems(1) & "--" & .Item(i).SubItems(2)
End If
End If
Next
End With
End Sub
Private Sub Form_Load()
Dim i As Long
With Me.ListView1
.Checkboxes = True
.Appearance = cc3D
.View = lvwReport
.FullRowSelect = True
.LabelEdit = lvwManual
.ColumnHeaders.Add 1, "x", "哈"
.ColumnHeaders.Add 2, "xx", "哈哈"
.ColumnHeaders.Add 3, "xxx", "哈哈哈"
End With
With Me.ListView1
For i = 1 To 10
.ListItems.Add
With .ListItems.Item(i)
.Key = "x" & CStr(i)
.Text = "测试" & CStr(i)
.SubItems(1) = "测试" & CStr(i)
.SubItems(2) = "测试" & CStr(i)
End With
Next
End With
End Sub
补充:VB , 控件