Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listview help

Status
Not open for further replies.

Poloboy

Technical User
Aug 26, 2002
58
US
Hi,
I have a listview in Report view. I have 2 columns, the first one i want to add my own text and colunm 2 pulling data from the database at run time.

Example:
Column 1 Column 2

Firstname Jimmy <---from database
Lastname Newtron <---from database
Address 1234 Main st <----from database
City London <-----from database

Thanks
 
I would do it slightly differently:

LV1.ListItems.Clear
LV1.ColumnHeaders.Clear
LV1.View = lvwReport
LV1.ColumnHeaders.Add , , "Firstname", 2500
LV1.ColumnHeaders.Add , , "Lastname", 2500, 2
LV1.ColumnHeaders.Add , , "Address", 3500, 2
LV1.ColumnHeaders.Add , , "City", 300, 0

Then just loop through the database adding items to the ListView
Set itmx = LV1.ListItems.Add(, , "Jimmy") '<---from database
itmx.SubItems(1) = "Newtron" '<---from database
itmx.SubItems(2) = "1234 Main st" '<----from database
itmx.SubItems(3) = "London" '<-----from database

[gray]Experience is something you don't get until just after you need it.[/gray]
 
I have a lot of information to display. I don't want to have it scroll horizontally to view all the informations. I just want to have 2 columns so it's easy to view the informations. Can this be done? Thanks
 
I don't want to have it scroll horizontally to view all the information" Well doing it your way you would have to scroll vertically far more frequently because you are using 4 lines for every entry instead of one.

With my suggestion you will be able to sort by each field so you could sort by name, town or city etc. If you need to view all the data for an entry you can click on the particular line and display all the data for that entry in a text box.

The values after each field in the column header determine the width of each cell (2500, 3500 etc). You can change these values to suit your preference.


[gray]Experience is something you don't get until just after you need it.[/gray]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top