Solved

ListView Questions

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

752 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