如何checkedlistbox里面选取的项添加到textbox里面?
我在form1里面添加了一个checkedlistbox、一个textbox、一个button。我想实现,按下button按钮,checkedlistbox里面选取的项添加到textbox里面。
先将textbox控件的multiline属性设置为true
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
For i = 1 To 20
CheckedListBox1.Items.Add("这是第" & CStr(i) & "项")
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
For i = 0 To CheckedListBox1.CheckedItems.Count - 1
TextBox1.Text += (CheckedListBox1.CheckedItems(i) & ControlChars.CrLf)
Next
End Sub