[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Read ListView Items by Column Name

Posted on 2011-09-06
5
Medium Priority
?
425 Views
Last Modified: 2012-05-12
Hi, We use listView in our vb.net project (VB 2005). up until now we've been Referencing the item and sub item by index.  We'd like to change that and Reference item by it's column name.
for example:
it we have four columns in our list. i
Column1, Column2,Column3,Column4

current Code
        For i As Integer = 0 To listView1.Items.Count - 1
            Console.WriteLine(listView1.Items(i).SubItems(1).Text)
        Next

We'd like to use listView1.Items(i).SubItems("Column1").Text

I can't figure out how to do this currently, because it's not working right now.
0
Comment
Question by:vb7guy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 28

Expert Comment

by:strickdd
ID: 36490150
0
 

Author Comment

by:vb7guy
ID: 36490315
Thanks for the response. but this post doesn't work with VB.net
0
 
LVL 28

Accepted Solution

by:
strickdd earned 1000 total points
ID: 36490343
What is the issue with VB.net? My guess is it is a syntax change that needs to be made:

listView1.Columns("NameKey").Index
0
 

Author Comment

by:vb7guy
ID: 36490398
Here, I figured it out on my own. too bad, this isn't well documented in books online.

Console.WriteLine(listView1.Items(i).SubItems(listView1.Columns.IndexOfKey("column1")).Text)
0
 

Author Closing Comment

by:vb7guy
ID: 36490402
Since your response was kind of partial. I'll accept it as the solution.
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question