Results 1 to 3 of 3

Thread: [Resolved] Listview with Multi columns to array?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    [Resolved] Listview with Multi columns to array?

    I am currently using the following code to store all of the items from a listbox control in an array, and then build a string based on the array items, trimming the last two character of the string to remove the ", ". I am looking to do something similiar for my multicolumn listview control but am concerned about how to store the multiple subitems for each item in the array.

    Code:
    Dim myStr (listbox1.items.count) as String
     'store all active medications information in an array & build a string
            For i As Integer = 0 To listbox1.Items.Count - 1
                myStr(i) = listbox1.Items.Item(i).ToString
            Next
    
     myStrResult = String.Join(", ", myStr)
     myStrResult = Left(myStrResult, Len(myStrResult) - 2)
    Thanks for any suggestions.

    -Jeremy
    Last edited by hipopony66; Feb 25th, 2009 at 03:22 PM.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Listview with Multi columns to array?

    try this:

    vb Code:
    1. Dim myStrResult As String = ""
    2.  
    3. Dim myStr(ListView1.Items.Count - 1, ListView1.Columns.Count - 1) As String
    4. 'store all active medications information in an array & build a string
    5. For y As Integer = 0 To ListView1.Items.Count - 1
    6.      For x As Integer = 0 To ListView1.Columns.Count - 1
    7.           myStr(y, x) = ListView1.Items(y).SubItems(x).Text
    8.           myStrResult &= myStr(y, x) & ", "
    9.      Next
    10.      myStrResult = myStrResult.Substring(0, myStrResult.Length - 2)
    11.      myStrResult &= Environment.NewLine
    12. Next

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Re: Listview with Multi columns to array?

    Thanks for the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width