Solved

ListView Questions

Posted on 2000-02-29
2
188 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

757 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

18 Experts available now in Live!

Get 1:1 Help Now