Solved

ListView control

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

743 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