Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 20th, 2007, 06:06 PM
Registered User
 
Join Date: Dec 2006
Location: Dungerpur, Gujrat, India.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default reading value from listview

I have a listview control in vbnet2003
I have populated the list view
Now when user selects an item the value in 4th column has to be displayed
i have coded for selecting the item but having problem in displaying the value

[i]Dim sValue as decimal
Dim item As ListViewItem = lvwStudents.SelectedItems(0)[/
i]

at this stage i have to display the value from 4th column of listview control of the selected item. Column name is "FeesDue" . The display can be a message box
Please Help me

Yasho

rSd
__________________
rSd
Reply With Quote
  #2 (permalink)  
Old July 21st, 2007, 07:55 AM
Registered User
 
Join Date: Dec 2006
Location: Dungerpur, Gujrat, India.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Assuming that it is not possible to read value from listview, I decided to work around it.
I created an 2 dimensional array and while loading values in listview I loaded my array too.

I also captured my row select index and used the value of index to extract the value from array for the particular listviewColumn.

Experts please comment on my technique and suggest if there is any better way and also about my assumption that values from listview can not be read.

rSd
Reply With Quote
  #3 (permalink)  
Old July 22nd, 2007, 04:22 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,190
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

yes you can.. the listview (like the gridview and others) has a way to loop around all the items in a specific row... if you have the select index of the row you can retrieve it... I don't have an example here.. but this can be easily found if you google a little...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
Reply With Quote
  #4 (permalink)  
Old July 23rd, 2007, 06:05 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: India.
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india
Default

hi...try this

lvData.SelectedItems(0).SubItems(3).Text

Reply With Quote
  #5 (permalink)  
Old August 25th, 2010, 02:05 AM
Authorized User
 
Join Date: Dec 2006
Location: Tucson, AZ, USA.
Posts: 43
Thanks: 4
Thanked 0 Times in 0 Posts
Send a message via MSN to Yasho
Default Reading listview items

I have the same problem. I need to read from listview. Listview may contain from 1 to 10 rows of data in multiple columns. I populated the listview using a data adapter from 3 different tables as per users choice and need. Now i want to save the contents of this listview to another table. Experts help the naives! If it is a not easy to do or not possible to do then please let us know
"Cant be done" will also be as helpful as "can be done and with the solution".
__________________
yvk
Reply With Quote
  #6 (permalink)  
Old August 26th, 2010, 12:51 AM
Authorized User
 
Join Date: Dec 2006
Location: Tucson, AZ, USA.
Posts: 43
Thanks: 4
Thanked 0 Times in 0 Posts
Send a message via MSN to Yasho
Thumbs up read from listview

OK guys I solved the problem

Code:
dim i , j as integer
 
count = lvwTest.Items.Count  ' count of items (number of rows in the list view
For i = 0 To count - 1
 
For j = 0 To 1  'set j value from 0 to (countof columns-1).  example listview has 2 columns
Dim iRow AsInteger = i
Dim iCol AsInteger = j
Dim value AsString = lvwTest.Items(iRow).SubItems(iCol).Text
Next j
Next i
You can copy this code and put in your program, just change the listview name and set the numbers of columns.
suggestion to store databack in database--- I would use a multi dimensional dynamic array to store the data from list view and and then data adapter update method to store back in data base
__________________
yvk
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ListView asters VB.NET 2002/2003 Basics 0 March 27th, 2008 05:00 AM
About Listview control yuetqu BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 August 15th, 2006 04:56 AM
listView AristotleYu ASP.NET 2.0 Basics 0 May 11th, 2006 04:54 AM
ListView Control jlr27613 C++ Programming 1 September 14th, 2004 12:58 PM
Listview Question omb Pro VB 6 1 September 9th, 2003 02:24 AM



All times are GMT -4. The time now is 10:16 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.