How to display "all" the items of listbox?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kimiraikkonen

    How to display "all" the items of listbox?

    Hi,
    I want to display ALL the items (includes unselected items) of listbox
    control. How can i code this? Should i use "for each" or other?

    For example:
    Assume you have a listbox with 3 items sth like:

    Hello
    There
    Guys

    And i want to display them in the same format within a messagebox with
    seperated each line(maybe i have to use " + vbnewline"?).

    How to do this?

    Thanks!
  • Teemu

    #2
    Re: How to display "all&qu ot; the items of listbox?


    "kimiraikko nen" <kimiraikkonen8 5@gmail.comkirj oitti viestissä
    news:c29d4209-1021-45ad-901b-d50ee1740a1d@t1 g2000pra.google groups.com...
    Hi,
    I want to display ALL the items (includes unselected items) of listbox
    control. How can i code this? Should i use "for each" or other?
    >
    For example:
    Assume you have a listbox with 3 items sth like:
    >
    Hello
    There
    Guys
    >
    And i want to display them in the same format within a messagebox with
    seperated each line(maybe i have to use " + vbnewline"?).
    >
    How to do this?
    >
    Thanks!
    ListBox1.Items. Add("1")
    ListBox1.Items. Add("2")
    ListBox1.Items. Add("3")

    Dim buffer As New System.Text.Str ingBuilder
    For i As Integer = 0 To ListBox1.Items. Count - 1
    buffer.AppendLi ne(ListBox1.Ite ms(i).ToString)
    Next
    MsgBox(buffer.T oString)

    -Teemu

    Comment

    • Armin Zingler

      #3
      Re: How to display &quot;all&qu ot; the items of listbox?

      "kimiraikko nen" <kimiraikkonen8 5@gmail.comschr ieb
      Hi,
      I want to display ALL the items (includes unselected items) of
      listbox control. How can i code this? Should i use "for each" or
      other?
      >
      For example:
      Assume you have a listbox with 3 items sth like:
      >
      Hello
      There
      Guys
      >
      And i want to display them in the same format within a messagebox
      with seperated each line(maybe i have to use " + vbnewline"?).
      >
      How to do this?
      If language = VB 2008 AndAlso all items in the list are Strings:

      MsgBox(String.J oin(vbCrLf, Me.ListBox1.Ite ms.Cast(Of String).ToArray ))


      Armin

      Comment

      • Teemu

        #4
        Re: How to display &quot;all&qu ot; the items of listbox?


        "Armin Zingler" <az.nospam@free net.dekirjoitti viestissä
        news:%23REqwuVR IHA.3676@TK2MSF TNGP06.phx.gbl. ..
        If language = VB 2008 AndAlso all items in the list are Strings:
        >
        MsgBox(String.J oin(vbCrLf, Me.ListBox1.Ite ms.Cast(Of String).ToArray ))
        Quite handy. LINQ makes everything too easy. :-)

        -Teemu

        Comment

        Working...