我需要幫助我將第一個未選擇的元素從串列框中復制到另一個的代碼,我已經知道如何復制所有未選擇的元素,如下所示,但我只需要從 lisbox 中復制第一個 Elemnet:
For i As Integer = 0 To ListBox3.Items.Count - 1
If ListBox3.GetSelected(i) Then
ListBox1.Items.Add(ListBox3.Items(i))
Else
ListBox1.Items.Add(ListBox3.Items(i))
End If
Next
謝謝
uj5u.com熱心網友回復:
你可以試試這個方法。它會復制所有未選擇的,但很容易修改為只復制第一個找到的。
Private Sub CopyUnselectedButton_Click(sender As Object, e As EventArgs) Handles CopyUnselectedButton.Click
For iterator As Integer = 0 To SourceListBox.Items.Count - 1
Dim item As Object = SourceListBox.Items(iterator)
If Not SourceListBox.SelectedItems.Contains(item) Then
DestListBox.Items.Add(SourceListBox.Items(iterator))
Exit For
End If
Next
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/442646.html
標籤:VB.net
