使用一个List控件,增加如下几个项目,并带有checkbox
aaaaa
bbbbb
ccccc
ddddd
当选择了每一行的check后,要求在TEXT中显示出我所选的每一行的文字,并能自动显示出任意选择了行数.如:如果我选择了第一行和第三行,则在TEXT中显示aaaaa,ccccc,如果选择第二行和第三行,则在text中显示bbbbb,ccccc等,该如何解决呀
aaaaa
bbbbb
ccccc
ddddd
当选择了每一行的check后,要求在TEXT中显示出我所选的每一行的文字,并能自动显示出任意选择了行数.如:如果我选择了第一行和第三行,则在TEXT中显示aaaaa,ccccc,如果选择第二行和第三行,则在text中显示bbbbb,ccccc等,该如何解决呀
If List.Item(i).Checked then
TextBox.Text = List.Item(i)
End If
Next
Text1.Text = ""
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then
If Text1.Text = "" Then
Text1.Text = List1.List(i)
Else
Text1.Text = List1.List(i) + "," + Text1.Text
End If
End If
Next i
End SubPrivate Sub Form_Load()
List1.AddItem "aaaa"
List1.AddItem "bbbb"
List1.AddItem "cccc"
List1.AddItem "dddd"
End Sub
Private Sub Command1_Click()
Text1.Text = ""
Dim A() As String, I As Integer, K As Integer
K = 0
For I = 0 To List1.ListCount - 1
If List1.Selected(I) Then
K = K + 1
ReDim Preserve A(1 To K)
A(K) = List1.List(I)
End If
Next
Text1.Text = Join(A, ",")
Erase A
End SubPrivate Sub Form_Load()
Dim I As Integer
For I = 0 To 25
List1.AddItem String(5, Chr(I + 97))
Next
End Sub