Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    61
    Thanks
    12
    Thanked 0 Times in 0 Posts

    [VB.NET] Adding selected item from listview1 to listview2

    This is the first time using listview and for the life of me i can't get it figured out.


    Code:
    Dim selectedItems = (From i In ListView2.SelectedItems)
    
            For Each selectedItem In selectedItems
    
                ListView1.Items.Add(selectedItem)
                Label3.Text = "Fruit Basket: " & ListView1.Items.Count
    
            Next

    I Figured it out

    Code:
      Dim ItemI As ListViewItem
                Dim ItemJ As ListViewItem
                Dim PROG As Integer
                Dim count As Integer
                Dim PDC As Integer = kiword.ListView2.Items.Count
    
                For i As Integer = kiword.ListView2.Items.Count - 1 To 0 Step -1
                    ItemI = kiword.ListView2.Items(i)
                    PROG = PROG + 1
    
                    For z As Integer = i + 1 To kiword.ListView2.Items.Count - 1 Step 1
                        itemj = kiword.ListView2.Items(z)
                        If itemI.Text = itemJ.Text Then
                            kiword.ListView2.Items.Remove(itemJ)
                            count = count + 1
                            Exit For
                        End If
                    Next z
                Next (i)
    
            Catch ex As Exception
    
            End Try
    Last edited by kor81; 08-09-2012 at 06:58 PM.


 

Posting Permissions

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