• Welcome to Valhalla Legends Archive.
 

[SOLVED] Listview Sub Items

Started by QwertyMonster, May 30, 2005, 05:57 AM

Previous topic - Next topic

QwertyMonster

Hey. My listview wont add sub items for some odd reason. Any ideas why?


        frmMain.ListView1.ListItems.Add(, , username, , 7).ListSubItems.Add , , ping, Events.GetLagIcon(ping)


GetLagicon:


Public Function GetLagIcon(ping As String) As Long
  If ping = -1 Then GetLagIcon = 22 '-1 ms lag bar (blue)
  If ping = 0 Then GetLagIcon = 22 '0ms lag bar (half green)
  If ping > 5 And ping < 100 Then GetLagIcon = 16 '1 green
  If ping > 99 And ping < 200 Then GetLagIcon = 17 '2 green
  If ping > 199 And ping < 300 Then GetLagIcon = 17 '3 yellow
  If ping > 299 And ping < 400 Then GetLagIcon = 18 '4 yellow
  If ping > 399 And ping < 500 Then GetLagIcon = 19 '5 red
  If ping > 499 And ping < 600 Then GetLagIcon = 20 '6 red
  If ping > 599 Then GetLagIcon = 21 '7 dark red
' If Ping > 699 Then GetLagIcon = 146 '8 dark red
End Function


My listview is put for the imagelist with those images in. Any ideas people?

Ringo

Quote from: QwertyMonster on May 30, 2005, 05:57 AM
Hey. My listview wont add sub items for some odd reason. Any ideas why?


        frmMain.ListView1.ListItems.Add(, , username, , 7).ListSubItems.Add , , ping, Events.GetLagIcon(ping)


GetLagicon:


Public Function GetLagIcon(ping As String) As Long
  If ping = -1 Then GetLagIcon = 22 '-1 ms lag bar (blue)
  If ping = 0 Then GetLagIcon = 22 '0ms lag bar (half green)
  If ping > 5 And ping < 100 Then GetLagIcon = 16 '1 green
  If ping > 99 And ping < 200 Then GetLagIcon = 17 '2 green
  If ping > 199 And ping < 300 Then GetLagIcon = 17 '3 yellow
  If ping > 299 And ping < 400 Then GetLagIcon = 18 '4 yellow
  If ping > 399 And ping < 500 Then GetLagIcon = 19 '5 red
  If ping > 499 And ping < 600 Then GetLagIcon = 20 '6 red
  If ping > 599 Then GetLagIcon = 21 '7 dark red
' If Ping > 699 Then GetLagIcon = 146 '8 dark red
End Function


My listview is put for the imagelist with those images in. Any ideas people?

Stick a new ListView object on your form,  in the properties window click "custom" and then click the "column header" tab.
In the index tab, do u have more than 1 column? if not:
click "Insert Column" and set its width to your imagelist's icon width (unless u want text behind the lag icon, then set it longer) and make sure "Alignment" is set to 0 (left).

Now stick a cmd button on your form, and add somthing like this to the click event:


With frmMain.ListView1.ListItems.Add(, , UserName, , 7)
    .ListSubItems.Add , , Ping, Events.GetLagIcon(Ping)
End With


For a dbl check, you should have 2 colums, 1 being for user names and there chat icons and 2 being for the lag icon.
The width of your 1st column should be set to the desired width to alow for a username to be displayed (+ its chat icon) and your 2nd column should be set to the width of the imagelist's icons.
Then set your whole listview width to match these widths (so not to gain scroll bars at the bottom of your listview when users are in it).

That should help understanding how to display a 2nd row with a listview (if u wasnt sure already), If that doesnt help, maybe you could post the declared verible for ping, because i dont think you should be passing down the ping value to the function as a string, but maybe as a long or integer. (It could be due to the way you are declareing it)

Hope that helps.

QwertyMonster

Thanks. I just relised my problem. I didnt have any column headers. Thanks.