Results 1 to 7 of 7

Thread: ListView FindItem Question

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    11

    ListView FindItem Question

    I have 2 list view’s and both have 3 fields

    LvInv1 and lvAll2

    First field is ID, second field is Qty, and third is a date.

    What happens is lvInv1 Qty is taken out of and moved into lvAll2 listview. So the Qty In lvInv1 goes down and Qty in lvAll2 goes up.

    So when I remove a single row in LvAll2, whats supposed to happen is, the qty from lvall2 is remove and the qty lvinv1 should be updated (lv1 +lv2) now all this depends on which ID is picked.

    I have looked over a few listview tutorials but none seem to work.

    Any help would be appreciated.
    Thank you

  2. #2
    Fanatic Member vbasicgirl's Avatar
    Join Date
    Jan 2004
    Location
    Manchester, UK
    Posts
    1,016

    Re: ListView FindItem Question

    If you are managing to update the second listview by updating the Qty, why cant you do the opposite ?, do you update the second listview with ID aswell.

    Welcome to the forum

    Casey.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: ListView FindItem Question

    Welcome to the forums.

    How are the listviews populated? Are you using a database? If so, then I would make the modifications there, and simply reload the ListViews.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    11

    Re: ListView FindItem Question

    If you are managing to update the second listview by updating the Qty, why cant you do the opposite ?, do you update the second listview with ID aswell.
    The Update of the 1st listview does not happen until the done button is pressed. which works fine for the first entry.
    But lets say you come back to the form that you previously transfered 5 from qty of 10 and pressed done...now both sides have 5 as their qty!
    But lets say 2nd time you want to remove the five and only allocate 2, so when you press 5, i want the 1st listview to show 10, and not 5 this way the user will not get confused.

    Yes ID is transefered aswell thats why i was thinking maybe finditem ID, and get the qty and add it to 1st list view current qty, and refresh it.

    How are the listviews populated? Are you using a database? If so, then I would make the modifications there, and simply reload the ListViews.
    The calls a stored procedure which gets the information from the database.

  5. #5
    Fanatic Member vbasicgirl's Avatar
    Join Date
    Jan 2004
    Location
    Manchester, UK
    Posts
    1,016

    Re: ListView FindItem Question

    If i understand you correctly, try this.
    Code:
    Dim LvItm As ListItem, SubVal As Integer
    
    'try to find the id in lvinv1 using the id from lvall2
    Set LvItm = LvInv1.FindItem(lvAll2.SelectedItem.Text)
    
    'check to see if it returns anything
    If Not LvItm Is Nothing Then
    
     'get the value of the qty of lvall2
     SubVal = Val(lvAll2.SelectedItem.SubItems(1))
     
     'add the value of the found qty in lvinv1
     SubVal = SubVal + Val(LvItm.SubItems(1))
     
     'update the value in lvinv1
     LvInv1.ListItems(LvItm.Index).SubItems(1) = CStr(SubVal)
     
     'remove the itm in lvall2
     lvAll2.ListItems.Remove lvAll2.SelectedItem.Index
    
    End If
    Casey.

  6. #6

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    11

    Re: ListView FindItem Question

    thanks a bunch i will try this and will get back to you!

  7. #7

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    11

    Re: ListView FindItem Question

    you are a genius!!!
    thanks a lot for all your help
    very much appreciated!!!!!!

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