Solved

ListView control

Posted on 1998-07-16
3
203 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now