Solved

ListView control

Posted on 1998-07-16
3
215 Views
Last Modified: 2010-05-03
Hi !
How does one add items to be displayed in a list view control. The Additem method doesn't seem to work. I need  to add multiple columns and rows from a file to a listView control, sort the data and then write the data back to the file. Could someone put me on the right track? Any help is welcome.
Regards,
PM
0
Comment
Question by:PriyaMani
[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
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
tward earned 50 total points
ID: 1465981
This will add Six rows of 2 Columns Each:

  Dim itmX As ListItem
  Set itmX = ListView1.ListItems.Add(, Chr(34) & "1111" & Chr(34), "TESTING1")
  itmX.SubItems(1) = "TESTING 1 COLUMN 2"

  Set itmX = ListView1.ListItems.Add(, Chr(34) & "1112" & Chr(34), "TESTING2")
  itmX.SubItems(1) = "TESTING 2 COLUMN 2"
 
  Set itmX = ListView1.ListItems.Add(, Chr(34) & "1113" & Chr(34), "TESTING3")
  itmX.SubItems(1) = "TESTING 3 COLUMN 2"
 
  Set itmX = ListView1.ListItems.Add(, Chr(34) & "1114" & Chr(34), "TESTING4")
  itmX.SubItems(1) = "TESTING 4 COLUMN 2"
 
  Set itmX = ListView1.ListItems.Add(, Chr(34) & "1115" & Chr(34), "TESTING5")
  itmX.SubItems(1) = "TESTING 5 COLUMN 2"
 
  Set itmX = ListView1.ListItems.Add(, Chr(34) & "1116" & Chr(34), "TESTING6")
  itmX.SubItems(1) = "TESTING 6 COLUMN 2"

If you need more help just add a comment and I'll help you out!
0
 

Author Comment

by:PriyaMani
ID: 1465982
Thanks for the code 'tward' . But, I still haven't figured out the way to retrieve the sorted data from the list view. Is it possible to get the data back from the control and write it to the file?
I appreciate your help

PriyaMani
0
 
LVL 7

Expert Comment

by:tward
ID: 1465983
Private Sub Command8_Click()

Dim InCounter As Long
Dim OutCounter As Long

For OutCounter = 1 To ListView1.ColumnHeaders.Count

     Call MsgBox(ListView1.ColumnHeaders(OutCounter).Text)

Next OutCounter

For OutCounter = 1 To ListView1.ListItems.Count

     Call MsgBox(ListView1.ListItems(OutCounter).Text)

     For InCounter = 1 To ListView1.ColumnHeaders.Count - 1

        Call MsgBox(ListView1.ListItems(OutCounter).SubItems(InCounter))

   Next InCounter

Next OutCounter

End Sub
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

749 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