Jump to content

How to transfer Selected items in a Listbox to a label??

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
toqi786

toqi786

    Newbie

  • Members
  • Pip
  • 8 posts
hi,
Im trying to transfer the selected items in a listbox to a label!

the listbox is on multisimple in the selection mode property.

For Each item In ListBox1.SelectedItems

            Label1.Text = item

        Next

However this would only, this will only show the last selected item in the label.

Can someone please help me, and explain to me how to fix my problem?

Thanx

toqi786

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
For Each item In ListBox1.SelectedItems
            Label1.Text = Label1.Text+item
        Next

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
toqi786

toqi786

    Newbie

  • Members
  • Pip
  • 8 posts
this is still showing only the bottom item selected in the listbox :confused:

#4
Grue

Grue

    Newbie

  • Members
  • PipPip
  • 12 posts

toqi786 said:

this is still showing only the bottom item selected in the listbox :confused:

Perhaps you're stuff in the listbox is lengthy and there isn't enough room to reveal it all? I used that For Next loop myself and it works just fine. Mind, it only makes a single line.

Which, btw, if you don't want the items to stick together as one big glob of text, I suggest adding a space:

For Each item In ListBox1.SelectedItems
            Label1.Text = Label1.Text + item + " "
        Next