Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • *Gurus*
Posted

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

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

  • 9 months later...
Posted

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!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...