Results 1 to 18 of 18

Thread: For...Next loop nested in another For...Next loop [RESOLVED]

Hybrid View

  1. #1
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    Do you know how to add items & subitems to a listview? You might want to look it up, try it, and post some code if you have problems.
    Basically, the first column is a listview item, and the other columns are subitems of that. They can be added with .Add, using the counter as an index.
    OK, here's an example. You can also add items & subitems at design time. There are other ways to do it.
    VB Code:
    1. Dim LvItem as New ListViewItem()   'this would be outside a loop
    2.  
    3. 'one way
    4. LvItem.Text = "Blah blah"  
    5. LvItem.SubItems.Add("yada yada")
    6. LvItem.Subitems.Add(strText)
    7. myListView.Items.Add(LvItem)
    8.  
    9. 'another way
    10. Set LvItem = myListView.Items.Add("Blah blah")
    11. LvItem.SubItems(1) = "yada yada"
    12. LvItem.SubItems(2) = strText
    13.  
    14. 'so
    15. Dim LvItem as New ListViewItem()
    16. For i = 1 to 12
    17.    For j = 1 to 12
    18.       Set LvItem = myListView.Items.Add(i)
    19.       LvItem.SubItems(1) = "x"
    20.       LvItem.SubItems(2) = j
    21.       LvItem.SubItems(3) = "="
    22.       LvItem.SubItems(1) = i * j
    23.    Next
    24. Next
    Last edited by salvelinus; Jun 22nd, 2004 at 11:47 AM.

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