如何把checklistBox里面的多个值选中并且移动到另个checklistBox框去,然后把选中的值在原有的checklistBox框里面删除
具体代码如下:
下面的代码是在添加和删除button的click事件里面写的,大家可以根据自己的需要写到你要用到的地方。
本人测试OK
说明点,代码离得循环要从大到小
Private Sub btnadd_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles btnadd.Click Try Dim j As Integer Dim s As String For j = clBox1.Items.Count - 1 To 0 Step -1 s = clBox1.Items.Count If clBox1.GetItemChecked(j) = True Then clBox2.Items.Add(clBox1.Items(j).ToString) clBox1.Items.RemoveAt(j) End If Next Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub btndelete_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles btndelete.Click Try Dim j As Integer For j = clBox2.Items.Count - 1 To 0 Step -1 If clBox2.GetItemChecked(j) = True Then clBox1.Items.Add(clBox2.Items(j).ToString) clBox2.Items.RemoveAt(j) End If Next Catch ex As Exception MsgBox(ex.Message) End Try End Sub