Jump to content

How to copy the first Unselected element from a listBox to another in vb.net


Recommended Posts

Hello All,

I need code that helps me to copy the first Unselected element from a listBox to another, I already know how to copy all unselected elements as below but I need to copy just the first Element from the lisbox:


                    For i As Integer = 0 To ListBox3.Items.Count - 1
                       If ListBox3.GetSelected(i) Then
                        End If



Link to comment
Share on other sites

  • 2 months later...

Usualy You can use Exit For, but then ..... hm, from Your's code items are copied from LB3 to LB1 no matter if they are selected or not.


Or you can use something like this:

DIm toCopy as Boolean

toCopy = true

itherate through list

if item is unselected and toCopy

     copy element

     toCopy = false


I am using c#, so VB(A) is somewhere between My ears..


Edited by goran
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...