Jump to content

Quick one about list box.

- - - - -

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

#1
yourmom615

yourmom615

    Learning Programmer

  • Members
  • PipPipPip
  • 33 posts
Hello,

I have four items that are in a list box and are being displayed through code not static items. My question is how to space these four items. See example below,

Item1
Item2
Item3
Item4

I am trying to accomplish and form of spacing at my discretion, like so...

Item1

Item2

Item3

Item4

Any suggestions would be helpful. Lastly, these items are not displayed using the collection
I am using VB.NET 2008

Thanks in advance.

#2
BWenz

BWenz

    Newbie

  • Members
  • Pip
  • 1 posts
How about :

ListBox1.Items.Add("one")

        ListBox1.Items.Add(ControlChars.NewLine)

        ListBox1.Items.Add("two")

        ListBox1.Items.Add(ControlChars.NewLine)

        ListBox1.Items.Add("three")

        ListBox1.Items.Add(ControlChars.NewLine)

        ListBox1.Items.Add("four")

        ListBox1.Items.Add(ControlChars.NewLine)

        ListBox1.Items.Add("five")


or if you are using a loop:

Dim counter As Integer

        Do While counter < 5


            ListBox1.Items.Add(counter)

            ListBox1.Items.Add(ControlChars.NewLine)

            counter = counter + 1

        Loop


Hope this helps