Solved

ListView control

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

688 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