Solved

ListView Questions

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
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 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…
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…

740 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