Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Yegg on September 19, 2004, 04:59 PM

Title: SelectedItem ToolTipText
Post by: Yegg on September 19, 2004, 04:59 PM
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?
Title: Re:SelectedItem ToolTipText
Post by: CrAz3D on September 19, 2004, 05:23 PM

lvChannel.SelectedItem.ToolTipText = "Hi there dood"
Title: Re:SelectedItem ToolTipText
Post by: Yegg on September 19, 2004, 05:36 PM
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.
Title: Re:SelectedItem ToolTipText
Post by: BaDDBLooD on September 19, 2004, 05:59 PM

lvChannel.Item(lvChannel.FindItem(Username).Index).ToolTipText = "Hello!"
Title: Re:SelectedItem ToolTipText
Post by: UserLoser. on September 20, 2004, 01:56 PM
Quote from: BaDDBLooD on September 19, 2004, 05:59 PM

lvChannel.Item(lvChannel.FindItem(Username).Index).ToolTipText = "Hello!"


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
Title: Re:SelectedItem ToolTipText
Post by: Warrior on September 20, 2004, 02:24 PM
Id also Assume that your could just call you Username , Ping, and Statstring stuff .

Edit:Spelling
Title: Re:SelectedItem ToolTipText
Post by: Stealth on September 20, 2004, 06:25 PM
Quote from: UserLoser. on September 20, 2004, 01:56 PM
Quote from: BaDDBLooD on September 19, 2004, 05:59 PM

lvChannel.Item(lvChannel.FindItem(Username).Index).ToolTipText = "Hello!"


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

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

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

   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


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.
Title: Re: SelectedItem ToolTipText
Post by: Michael on September 29, 2004, 08:15 PM
Why not good old On Error Resume Next before the finditem code?
Title: Re: SelectedItem ToolTipText
Post by: Stealth on September 29, 2004, 08:51 PM
Quote from: -MichaeL- on September 29, 2004, 08:15 PM
Why not good old On Error Resume Next before the finditem code?

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.
Title: Re: SelectedItem ToolTipText
Post by: Michael on September 30, 2004, 06:34 PM
Hey, thanks for the info i never new that :(