ListView Control - How Take Data Out of One ListView Control and Put It Into Another ListView Control Please Help

Public Class Form1
'Also Let Me Note - I will actually only want to move an item from lvOriginalList if the PersonAge is (lets say) '21
    'I have a ListView named
    ' lvOriginalList
    'It has the Following Columns
    ' IDNumber
    ' PersonName
    ' PersonAge
    'I have a Second ListView named
    ' lvRemovedList
    'It has the Following Columns
    ' IDNumber
    ' PersonName
    ' PersonAge
    'What I am attempting to do is read a row out of the first listview
    'Compare the IDNUmber, PersonName and PersonAge from out of it (lvOriginalList)
    'And If the Information is not present in the second ListView (lvRemoved) then Move it to it
    'And then Remove that Row from the First one (lvOriginalList)
    'What I have tried:
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'Populate lvOriginalList with Test Data
        Dim FileNum As Integer = FreeFile()
        Dim lvOriginalListCounter As Integer = 0
        FileOpen(FileNum, "d:\testdata\alphadata.txt", OpenMode.Input)
        lvOriginalList.Items.Clear()
        Do While Not EOF(FileNum)
            Dim OriginalIDNumber As String = ""
            Dim OriginalPersonName As String = ""
            Dim OriginalPersonAge As String = ""
            OriginalIDNumber = LineInput(FileNum)
            OriginalPersonName = LineInput(FileNum)
            OriginalPersonAge = LineInput(FileNum) 
            lvOriginalList.Items.Add(OriginalIDNumber, lvOriginalListCounter)
            lvOriginalList.Items(lvOriginalListCounter).SubItems.Add(OriginalPersonName)
            lvOriginalList.Items(lvOriginalListCounter).SubItems.Add(OriginalPersonAge) 
            lvOriginalListCounter = lvOriginalListCounter + 1
        Loop
        FileClose(FileNum)
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim OriginalIDNumber As String = ""
        Dim OriginalPersonName As String = ""
        Dim OriginalPersonAge As String = ""
        Dim CompareIDNumber As String = ""
        Dim ComparePersonName As String = ""
        Dim ComparePersonAge As String = ""
        Dim NumlvRemovedListItems As Integer = 0
        Dim CompareCounter As Integer = 0
        For Each item As ListViewItem In Me.lvOriginalList.Items
            '1  -   Get A Row Out of lvOriginalList
            OriginalIDNumber = item.Text
            OriginalPersonName = item.SubItems.Item(1).Text
            OriginalPersonAge = item.SubItems.Item(2).Text
            '2  -   Check To See If That Person Is Already  in lvRemovedList
            'Have to check to see if the lvRemovedList list Box is Empty
            NumlvRemovedListItems = lvRemovedList.Items.Count
            If NumlvRemovedListItems = 0 Then
                'the lvRemovedList listbox is empty
                'so add That Person as the first entry into the list box (lvRemovedList)
                lvRemovedList.Items.Add(OriginalIDNumber, NumlvRemovedListItems)
                lvRemovedList.Items(NumlvRemovedListItems).SubItems.Add(OriginalPersonName)
                lvRemovedList.Items(NumlvRemovedListItems).SubItems.Add(OriginalPersonAge)
                'then remove the player from the lvPlayerList listbox
                item.Remove()
            Else
                For Each itemb As ListViewItem In Me.lvRemovedList.Items
                    CompareIDNumber = item.Text
                    ComparePersonName = item.SubItems.Item(1).Text
                    ComparePersonAge = item.SubItems.Item(2).Text
                    If OriginalPersonName = ComparePersonName Then
                        'do nothing that persons name is already in the lvRemovedList list
                    Else
                        'do this because the player is not already in a matchin the lvRemovedList list
                        lvRemovedList.Items.Add(CompareIDNumber, CompareCounter)
                        lvRemovedList.Items(CompareCounter).SubItems.Add(ComparePersonName)
                        lvRemovedList.Items(CompareCounter).SubItems.Add(ComparePersonAge)
                    End If
                Next
            End If
            CompareCounter = CompareCounter + 1
        Next
    End Sub
End Class
'So what Am I doing Wrong
'It is only Removing the First entry out of lvOriginalList (but at least the remaining data is still there and the empty Row is removed)
'And only That first Entry is Appearing in lvRemovedList
'Please Help

Hello,
I have created a simple sample, you could focus on the button click event and edit it to fit your requirements by yourself.
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With ListView1
.View = View.Details
With .Columns
.Add("IDNumber")
.Add("PersonName")
.Add("PersonAge")
End With
With .Items
For index = 20 To 33
.Add("ID" & index, index - 19)
With ListView1.Items(.Count - 1).SubItems
.Add("Name" & index)
.Add(index)
End With
Next
End With
End With
With ListView2
.View = View.Details
With .Columns
.Add("IDNumber")
.Add("PersonName")
.Add("PersonAge")
End With
With .Items
For index = 21 To 22
.Add("ID" & index, index - 19)
With ListView2.Items(.Count - 1).SubItems
.Add("Name" & index)
.Add(index)
End With
Next
End With
End With
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
For Each item As ListViewItem In ListView1.Items
If CInt(item.SubItems(2).Text) < 29 Then
item.Remove()
Dim blContain As Boolean = False
For Each item2 In ListView2.Items
If item2.Text.ToString().Equals(item.Text.ToString()) Then
blContain = True
'Exit For
End If
Next
If Not blContain Then
ListView2.Items.Add(item)
End If
End If
Next
End Sub
End Class
Result.
Regards,
Carl
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • I need to get photos off a water damaged iPhone 3GS. Can I take out the component that has the photos (is this the main board?) and put it into another of the same phone to retrieve the photos? Please help

    I need to get photos off a water damaged iPhone 3GS. It spent time underwater, saltwater. I let it dry for a week, turned it on, the apple symbol came on, then it died. I need to retrieve my photos off it. Can I take out the component that has the photos (is this the main board?) and put it into another of the same phone to retrieve the photos? Please help

    You're talking about the logic board. The two most likely things to get toasted, with water damage, are the battery(it shorts out), & the logic board. The worst water damage would be salt water. I'm afraid your logic board is toast.

  • I have photos on my iphone 4 that i'm trying to transfer to iphoto.  The problem is when I plug the phone in, it only wants to transfer the new photos, not all.  How can I take all the photos off my phone and put them into iphoto?

    I have photos on my iphone 4 that i'm trying to transfer to iphoto.  The problem is when I plug the phone in, it only wants to transfer the new photos, not all.  How can I take all the photos off my phone and put them into iphoto? Even if there are duplicates, I'd like to make sure I get all the photos from my phone into iphoto.  Thanks

    To see all the photos on the phone, including photos that have already been imported into iPhoto, deselect the "Hide Photos Already Imported" checkbox. If the camera contains photos that have already been imported into iPhoto, those photos are hidden by default.

  • Can I take a selection from one clip and put it into another?

    I'm pretty new to this so thanks. I want to assemble a clip that has parts of three different takes. Splitting the screen works for a couple of the takes..but i'm wondering if I can use the four point matting to isolate a character and put him into another clip...the backgrounds are the same and the set up when shot is the same...but there is no blue or green screen involved so I'm wondering if this is possible in FCP. Hopefully the question makes sense...thanks!

    So you are trying to "cut out" your subject and paste him onto another take? Should be easy enough- just use the four or eight point matte to cut out a square around the subject, then layer that clip on top of the other take you want to superimpose him in. As long as the angle/lighting were the same, it should work. If you find you want a more complicated matte, try Tom's 50 Point Matter, which has a bezier curves option.

  • My iphone is stuck,  it says connect to itunes, and when I aconnect it to my pc, my pc says restore data but everything will be erased and I don't wanna lose everything. please help me

    my iphone is stuck,  it says connect to itunes, and when I aconnect it to my pc, my pc says restore data but everything will be erased and I don't wanna lose everything. please help me

    If you have a graphic of iTunes and a cable displayed on your iDevice then it is in Recovery mode.
    Check this to try an "exit"
    http://osxdaily.com/2011/01/08/iphone-recovery-mode/

  • So i just got an ipod touch and i want to take alll the suff of my zune and put it on my ipod can anyone help me also i didnt buy the music off the zune store i got it off lime wire

    i just got and ipod touch and i have been trying to take the music on my zune and put it on my ipod can anyone help me also i did not buy there music off of the zune store

    Ipod touch sync to itunes.
    You would need to put everything in itunes, then you can sync to ipod:
    iPod touch User Guide (For iOS 4.3 Software)

  • How do you Take songs from one iTunes library and put them on another(Mac)

    Well i have some songs that i don't really listen to anymore so i don't want them on my library or any of my ipods but i don't want to delete them because i bought them so i want to put them on another itunes library i created but i cant figure out how to take them out of my library and put them on the other one
    how do you do that?

    Open your other library, go to File>Add to library and navigate to the folder containing the files you want to add. Once they are in your new library delete them from the other library making sure that when you get the prompt to move them to trash say no. You should also back your purchases up to disc or to an external drive so you don't lose them of anything happens to your hard drive:
    How to back up your media in iTunes
    Back up your iTunes library by copying to an external hard drive

  • Is it possible to get my iTunes money out of one account and put it into another account?

    So I bought a Macbook Pro recently and a lady, who was working at the Apple Store, was putting in a Back to School giftcard for $100 in my account but I forgot the answers to my security questions. Since the lady already have put that money in that account, I was wondering if I make a new account and take the money out of my old account and I can put it my new account. Will it be possible or not? Please answer my question

    janelle27 wrote:
    ... I was wondering if I make a new account and take the money out of my old account and I can put it my new account. Will it be possible or not? Please answer my question
    This is not possible...

  • How to retrieve comments from one OfficeTask activity and use them in another OfficeTask activity for Multi level Approval sequential Workflow

    I'm designing a sequential site workflow using Visual Studio 2010 for Project Server 2010. In my case, I have following 6 stages in the workflow:
    1. InitialProposal Stage
    2. Approval Stage1 -- Needs approval from Approver Project Security Group Members1
    3. Rejection Stage
    4. Approval Stage2 -- Needs approval from Approver Project Security Group Members 2
    5. Execution Stage
    6. Completed Stage
    Requirement is workflow should move to Approval stage2 from Approval stage1  if approved by all members of Approver Project Security Group1and it should move to Rejection Stage even if a single member rejects it.
    Workflow should move from Approval Stage2 to Execution Stage if approved by all members of Approver Project Security Group2 and it should move back to Approval Stage1 on rejection by a single member of the group.
    I'm using inbuilt PSWApproval content type and OfficeTask activity for creating approval task for the group members at both stages.
    On task rejected in Approval stage2, task will be assigned again to Approval Stage1 and I want to show comments given by members of Approver Project Security Group2 to the members of Approver Project Security Group1 with this assigned task
    but I'm not able to retrieve comments from officeTask activity.
    My question is where exactly these comments are saved? how can we retrieve them and use them in another officetask activity? If this is not possible then what is the possible solution for meeting above mentioned business requirement?

    Hi Paul,
    Thanks for your suggestion.
    By comments field I'm assuming OfficeTask.Comments field. Problem is, this field is always null. I tried accessing this field in CheckExitCondition activity as well as in OnTaskCompleted but in both the cases, it was null only(I wrote comments while approving
    the task).
    I used a code activity within OnTaskCompleted activity and following code for accessing Comments and Description fields:
    public string officeComments;
            public string officeDescription;
            private void TaskCOmplete(object sender, EventArgs e)
                CodeActivity Sender = (CodeActivity)sender;
                Microsoft.Office.Workflow.Actions.OfficeTask ofctask1 = ((CompositeActivity)Sender.Parent).Parent as Microsoft.Office.Workflow.Actions.OfficeTask;
                officeComments = ofctask1.Comments;
                officeDescription = ofctask1.Description;          
    Please tell me if I'm doing anything wrong here, I'm very new to Workflows. Also, do I need to set any specific property of officeTask for retriving comments?
    Thank you

  • How would I take money from one iTunes account and put it on another iTunes account?

    Trying to swap money from one iTunes account to another iTunes account so I can make in app purchases in a certain game. Can anyone help me out please?

    You can't do this yourself. Click here and ask the iTunes Store staff to put it back onto the card; they'll only do this if none of the balance has been spent.
    (123252)

  • How can I merge documents with layout written with pages? How can I copy pages-document with layout and paste it into another pages document?

    Hi
    I am working with pages for a book and have made already a layout whre photos and graphs etc. are partly outside of the area for the text, their posotion is not fixed the the text.
    And now I nedd support: When I add text or a photo to the layout the text moves and the unfixed photos etc. keep there position. This means I have to update each photo or graph to shift it to the new position ore I have to place photos etc. within the frame of the text, which is not the kind of layout I am going for.
    I hope for two reliefs, which I do not know how to realize it.
    1. If I specify each chapter as a new partition starting with own page (then I hoped) the new section would shift together into a new page and the positions of photos etc. and text would stay fix. But unfortunately this seeems not to be the case. Question: is this possibe orno? If yes, how to do it?
    I could divede the whole txt chapter by chapter into individual documents, which are seperatly created and worked. At the end I would have to merge all this document into one. Is it possibe to merge different pages-document into one document?
    Who can help me?
    Thanks Hartmut

    Images and other object can either be floating or be inline. Yours are floating and will not move with the text. Inline object will move with the text but can't be outside the text layer. It doesn't help if you have created section in the document. Floating images doesn't care. Nor will it help if you create several documents that you want to merge later. Doesn't make any difference.
    My suggestion is that until your text is finished you have the images inline. Then as a last editing you can start make the images floating and move them a little.

  • Is there a way to take the code form my iweb site and put in into iweb on a different mac?

    I had built my website on an old laptop - the hard drive shattered - and yes i was bad and didnt back up.....
    I want to update my site - but i dont want to start all over  - i just want to make some changes and re publish -
    Can i get the current code off ther website- put it back into iweb make my changes and republish???
    THEN ILL BACK UP!!!!! lol

    THat would be a much better question for the iWeb support forum - thie is the iPhoto forum
    LN

  • My brother put a sim in phone then he took it out and put it into another phone but the number is still on imessage and i wanna delete the number and i dont wanna put money on the

    hhh

    Deactivate iMessage.
    Leave it as is and change the "Start New Converstations from" option in Settings > Messages.
    Do nothing....
    It really doesn't matter.
    What are you truly trying to accomplish?

  • I filmed several takes of the same scene for a movie. I trimmed the best clips from each take and put them into the project screen. However, I can't figure out how to make it flow seamlessly as one scene. Can someone please help me??

    I filmed several takes of the same scene for a movie. I trimmed the best clips from each take and put them into the project screen. However, I can't figure out how to make it flow seamlessly as one scene. Can someone please help me??

    1-800-676-2775  apple support   tech support 1 800 275 2273
    If your computer is on one minute before it freezes, than you have one minute to secure your serial number.
    click the apple----->click about this Mac ------> click on version----> until you see the serial number.  You may have to do this a couple of times if it freezes before you have all the numbers.  A camera might help.
    Good Luck

  • How can you take a photo from one event and put it in another, without dragging to desktop and dragging back into iPhoto and moving it to the event folder I want it in.

    As the title says I need help on how to take a photo from one event and put it in another, without dragging to desktop and dragging back into iPhoto and moving it to the event folder I want it in. Right now when I want to move a picture from one event to another I drag it to my desktop then delete it from iPhoto then I drag it back into iPhoto and put where I want it.An example would be taking a photo from the Christmas event and add it to a specific person event.  Can I do that within the events section without all the dragging. Also is there anyway I can remove duplicates from iPhoto without going through each and every file. Any help would be greatly appreciated.

    Apple doesn't make it easy to do what you want.  However, here's how I do it. 
    Select the photo you want to move and create a new Event for it via the Event ➙ Create Event menu option.
    In the Event mode select the new Event with the one picture and drag it onto the Event you want to move the photo to.

Maybe you are looking for