Valhalla Legends Forums Archive | Visual Basic Programming | SelectedItem ToolTipText

AuthorMessageTime
Yegg
Can ne1 show me how to *correctly* use tooltiptexts for selecteditems in a listview, like what stealthbot, binarychat, and many other bots have.
I was trying to use the line of code: (lvChannel is my listview)

lvChannel.SelectedItem.ToolTipText = 'coding here

This didn't work, so i switched it around a few times, and it stil failed. so, can ne1 help me?
September 19, 2004, 9:59 PM
CrAz3D
[code]
lvChannel.SelectedItem.ToolTipText = "Hi there dood"
[/code]
September 19, 2004, 10:23 PM
Yegg
Ok, sorry for confusing you, but i know how 2 do that, but i want it to giv each item a different tooltiptext, this way it can show each users separate stats, when i refer to stats, i mean ping and username, product and flags, mayb more.
September 19, 2004, 10:36 PM
BaDDBLooD
[code]
lvChannel.Item(lvChannel.FindItem(Username).Index).ToolTipText = "Hello!"
[/code]
September 19, 2004, 10:59 PM
UserLoser.
[quote author=BaDDBLooD link=board=31;threadid=8746;start=0#msg80968 date=1095634798]
[code]
lvChannel.Item(lvChannel.FindItem(Username).Index).ToolTipText = "Hello!"
[/code]
[/quote]

Note, that isn't a very good way to find a string in the listview. I'd suggest looping through the contents, and checking for the name. If you try to do lvChannel.FindItem("UserLoser").Index, and "UserLoser" doesn't exist, a runtime error will occur
September 20, 2004, 6:56 PM
Quarantine
Id also Assume that your could just call you Username , Ping, and Statstring stuff .

Edit:Spelling
September 20, 2004, 7:24 PM
Stealth
[quote author=UserLoser. link=board=31;threadid=8746;start=0#msg81093 date=1095706574]
[quote author=BaDDBLooD link=board=31;threadid=8746;start=0#msg80968 date=1095634798]
[code]
lvChannel.Item(lvChannel.FindItem(Username).Index).ToolTipText = "Hello!"
[/code]
[/quote]

Note, that isn't a very good way to find a string in the listview. I'd suggest looping through the contents, and checking for the name. If you try to do lvChannel.FindItem("UserLoser").Index, and "UserLoser" doesn't exist, a runtime error will occur
[/quote]

But we use On Error Resume Next to cover it up, right? ;)

If you're going to use FindItem, use it like this:

[code] Dim Found as ListItem

Set Found = lvChannel.FindItem("Username")

If Not (Found Is Nothing) Then
'do things with Found, ie Found.ToolTipText = "Hi!"
Set Found = Nothing
End If[/code]

That way, you destroy the reference to the found item when you're done, and you handle the chance that no item is found -- Found will be Nothing if it wasn't found.
September 20, 2004, 11:25 PM
-MichaeL-
Why not good old On Error Resume Next before the finditem code?
September 30, 2004, 1:15 AM
Stealth
[quote author=-MichaeL- link=topic=8746.msg82690#msg82690 date=1096506903]
Why not good old On Error Resume Next before the finditem code?
[/quote]

Why not actually handle the error as I did with a couple extra lines of code, rather than ignoring it? On Error Resume Next can cause problems down the road as your code progresses, it's best to avoid it whenever possible.
September 30, 2004, 1:51 AM
-MichaeL-
Hey, thanks for the info i never new that :(
September 30, 2004, 11:34 PM

Search