Results 1 to 9 of 9

Thread: Listview won't show text [resolved]

  1. #1

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Listview won't show text [resolved]

    This code won't actually show up any text in the listview even though its View property is set to Details.

    Code:
    		Dim lvi As ListViewItem
    
    		With lvProcesses
    			.Clear()
    
    			For i As Integer = 0 To Procs.GetUpperBound(0)
    				lvi = New ListViewItem(Procs(i).id)
    				lvi.SubItems.Add(Procs(i).Name)
    				lvi.SubItems.Add(Procs(i).Priority)
    				lvi.SubItems.Add(Procs(i).Boost)
    				.Items.Add(lvi)
    			Next i
    		End With
    What gives?
    Last edited by wossname; Apr 7th, 2004 at 02:37 AM.
    I don't live here any more.

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    Did you remember to add the columns first?

    You can add as many subitems you want, but without the columns to display them, nothing happens.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  3. #3

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Yeah, I did it from the properties pane in the IDE.

    ?!?
    I don't live here any more.

  4. #4
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    shoulddn't you declare a new listview item INSIDE the loop? that way, a new item is declared. otherwise, the loop overwrites the same one over and over.

    I thought the .clear method was the problem but that's out of the loop. (much like I am at work)lol

  5. #5

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Well, no because when the sub goes out of scope the listview will still contain all the data. Each new listviewitem is assigned, added to the control and then overwritten.

    I have just tried adding an item from the properties pane but that doesnt work either!

    Bug???
    I don't live here any more.

  6. #6
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    I wouldn't say it's a but because I've not read of one like that (not saying it's NOT but it would be the first I'VE heard of it.)

    hmm.is it possible to zip your project and post it? I'd like to see if it works or not on MY computer.

  7. #7
    Addicted Member Hole-In-One's Avatar
    Join Date
    Mar 2003
    Location
    Minnesota
    Posts
    195
    I've got your fix!

    Try this:

    Code:
    Dim lvi As ListViewItem
    
    		With lvProcesses
    			.Items.Clear()
    
    			For i As Integer = 0 To Procs.GetUpperBound(0)
    				lvi = New ListViewItem(Procs(i).id)
    				lvi.SubItems.Add(Procs(i).Name)
    				lvi.SubItems.Add(Procs(i).Priority)
    				lvi.SubItems.Add(Procs(i).Boost)
    				.Items.Add(lvi)
    			Next i
    		End With

    Just change ".Clear()" to ".Items.Clear()"

    I think ".Clear()" was clearing your columns too, therefore messing up your subitems.

    Worked for me!

  8. #8
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    that's right! I tried that out and it did the same for me. funny how a small detail like that can screw up your day

    at least it's not as bad as c++ where a 'dot' misplaced could take weeks to find!!!

  9. #9

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Brilliant!

    What a hero.
    I don't live here any more.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width