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 - display problem 1

Status
Not open for further replies.

ooops

MIS
Dec 21, 2000
91
US

What I'd like to achieve is having values written to the 2 column listView (should be on the same row). The codes below don't work out right. Everytime something added to SubItem, the value in the first column is pushed down to the next row. Any help is greatly appreciated.


lstViewAll.ListItems.Clear
lstViewAll.ColumnHeaders.Add , , "Jur"
lstViewAll.ColumnHeaders.Add , , "Facet"
lstViewAll.Sorted = True
lstViewAll.View = lvwReport

Do Until pFFeature Is Nothing
lstViewAll.ListItems.Add , , strJur
lstViewAll.ListItems.Add.ListSubItems.Add , , pFFeature.Value(1)
Set pFFeature = pFCursor.NextFeature
Loop
 
Do this instead:

Code:
Dim li As ListItem

Do Until pFFeature Is Nothing
    Setli = lstViewAll.ListItems.Add ,, strJur
    li.SubItems(0) pFFeature.Value(1) 'May be SubItems(1) can't remember if it is 0/1 based
    Set pFFeature = pFCursor.NextFeature
Next
 
try this:
Code:
Dim lvItem As ListItem
Dim lvSubItem As ListSubItem
Dim objColumnHeader As ColumnHeader

lstViewAll.ListItems.Clear
set objColumnHeader = lstViewAll.ColumnHeaders.Add()
objColumnHeader.Text = "Jur"
set objColumnHeader = lstViewAll.ColumnHeaders.Add()
objColumnHeader.Text = "Facet"
lstViewAll.Sorted = True
lstViewAll.View = lvwReport

Set lvItem = lstViewAll.ListItems.Add(, , strJur)
Do Until pFFeature is Nothing
   Set lvSubItems = lstViewAll.ListSubItems.add
   lvSubItem.Text = pFFeature.Value(1)
   set pFFeature = pFCursor.NextFeature
Loop

I'm assuming that all the pFFeatures are the subitems and all go with the same strJur
 

It still does the same thing, pushing down values of the first column to next row.
This is how it looks like if the Do Loop runs 4 times. I'm really frustrated over this. It should be something simple :-(( Thanks.

4545A
4545B
4678C
4758A
123
123
123
123
 
post the code that you have after making your changes
 
modity my code as:
Code:
Do Until pFFeature is Nothing
   Set lvItem = lstViewAll.ListItems.Add(, , strJur)
   Set lvSubItem = lvItem.ListSubItems.add
   lvSubItem.Text = pFFeature.Value(1)
   set pFFeature = pFCursor.NextFeature
Loop
 
Hi pkailas

I can't do: lstViewAll.ListSubItems.add
It doesn't have that property. I can see lstViewAll.ListItems but not lstViewAll.ListSubItems

Any idea how I should re-write them ? Thanks so much for your help.
 
Read my previous post. I had an error in my code..

use all the code I listed too. Declare lvItem as ListItem and lvSubItem as ListSubItem
 
Thank you so much. It already works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top