Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ListView control

Posted on 1998-07-16
3
Medium Priority
?
238 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 100 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

598 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