Solved

ListView Questions

Posted on 2000-02-29
2
190 Views
Last Modified: 2012-05-04
I am returning data from an AS400 database,

i.e. I click a node in a treeview and then the corresponding data is displayed (at the moment) in a ListBox.

I want to change this to output the data to a ListView, as I do not want the data displayed to be just text; I want to be able to click on the data that my treeview control has retrieved and perform furthur actions on it, (pretty much an emulation of Windows Explorer)

So far I cannot get my ListView to display any output

Can somebody provide with some code to:

i) Display the results of my nodeclick in a ListView, i.e. the nodeclick brings back data from a database, and I want to display it in a Listview.

ii) Code for how to manipulate data once it is in the ListView

Cheers,

Matt.

0
Comment
Question by:Matt_Unsworth
2 Comments
 
LVL 10

Accepted Solution

by:
caraf_g earned 30 total points
ID: 2568696
I am assuming that you had no problems displaying it in a list box, right?

In that case it's likely that you've just done something relatively basic wrong in your listview. If I'm mistaken, I'm sorry - didn't mean to be patronising....

Anyway, your list view's View property should be lvwReport

To add an item, check out the YourListView.ListItems.Add procedure

Make sure your list view has column headers.
use Yourlistview.ColumnHeaders.Add to add one


To set the text in a list item
ListItems(Index).Text = "Value"
This corresponds with the first column.

To set further columns, use the SubItems
SubItem(N) corresponds with column N+1

ListItems(Index).SubItems(1) = "hello"
ListItems(Index).SubItems(2) = "world"
etc.

You can't have more subitems than .ColumnHeaders.Count - 1

Er....

Also, check out the .SelectedItem property,


Some simple loops:

Dim objItem as ListItem

For lngCounter = 1 to YourListView.ListItems.Count
    Set objItem = YourListView.ListItems(lngCounter)
    With objItem
        .Text = "hello"
        .SubItems(1) = "World"
    End With
Next

to iterate through all items.

etc. etc. etc.

Does this help at all?
0
 

Author Comment

by:Matt_Unsworth
ID: 2579424
Cheers caraf_g  this has done the trick.

Matt.

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

776 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