|
-
Jan 18th, 2008, 01:07 PM
#1
Thread Starter
New Member
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
-
Jan 18th, 2008, 01:45 PM
#2
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.
-
Jan 18th, 2008, 02:06 PM
#3
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.
-
Jan 18th, 2008, 02:23 PM
#4
Thread Starter
New Member
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.
-
Jan 18th, 2008, 02:37 PM
#5
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.
-
Jan 18th, 2008, 02:39 PM
#6
Thread Starter
New Member
Re: ListView FindItem Question
thanks a bunch i will try this and will get back to you!
-
Jan 18th, 2008, 03:19 PM
#7
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|