John Robles Posted February 14, 2003 Posted February 14, 2003 how do you get/retrieve the values of the items in the listview? i'm doing a sales/inventory system and i use a listview control with columnheaders "qty"," item desc.", "unit price", and "amount". i have a command button to add all the items in the listview control. The way i want the program to work is if i press the purchase command button. each item in the "qty" column will be subtracted from the respective field in the database. How would i do that? Please provide the specific codes that i would use. i would really appreciate it. Quote
*Gurus* divil Posted February 14, 2003 *Gurus* Posted February 14, 2003 I don't know how you're doing the database side of things, but to iterate through a listview use the following code: Dim l As ListViewItem For Each l In ListView1.Items 'Do something with l.SubItems(1).Text, the first column, here Next l Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
John Robles Posted February 16, 2003 Author Posted February 16, 2003 got it, thanks! another question... how would you retrive values from each row starting from the first until the row is empty Quote
Leeus Posted December 12, 2003 Posted December 12, 2003 I used that code and on the first line of the loop (For Each l In ListView1.Items ) I get the following error: An unhandled exception of type 'System.InvalidCastException' occurred in RelayCrawler.exe Additional information: Specified cast is not valid. I'm going crazy! Quote
*Gurus* divil Posted December 12, 2003 *Gurus* Posted December 12, 2003 You declared l wrong. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.