Valhalla Legends Forums Archive | Battle.net Bot Development | [SOLVED] Listview Sub Items

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

[code]
        frmMain.ListView1.ListItems.Add(, , username, , 7).ListSubItems.Add , , ping, Events.GetLagIcon(ping)
[/code]

GetLagicon:

[code]
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
[/code]

My listview is put for the imagelist with those images in. Any ideas people?
May 30, 2005, 10:57 AM
Ringo
[quote author=QwertyMonster link=topic=11724.msg114162#msg114162 date=1117450633]
Hey. My listview wont add sub items for some odd reason. Any ideas why?

[code]
        frmMain.ListView1.ListItems.Add(, , username, , 7).ListSubItems.Add , , ping, Events.GetLagIcon(ping)
[/code]

GetLagicon:

[code]
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
[/code]

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

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:

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

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.
May 30, 2005, 12:32 PM
QwertyMonster
Thanks. I just relised my problem. I didnt have any column headers. Thanks.
May 30, 2005, 1:00 PM

Search