Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Yegg on November 05, 2004, 04:35 PM

Title: SelectedItem.ForeColor?
Post by: Yegg on November 05, 2004, 04:35 PM
ok, im trying to get my bot to have different forecolors for the channel list. for instance, if the user's flags are 2 or 18, it's forcolor would be White, normal flags would be yellow, and your own username would be Cyan.
heres the code i have and it isn't working at all. all it is doing is changing the color of the user at the top of the channel.

(all this code is under OnUser)

If flags = 2 Or flags = 18 Then
lvChannel.SelectedItem.ForeColor = vbWhite
lvPing.SelectedItem.ForeColor = vbWhite
ElseIf username = BNET.TrueUsername Then
lvChannel.SelectedItem.ForeColor = vbCyan
lvPing.SelectedItem.ForeColor = vbCyan
ElseIf Not flags = 2 Or Not flags = 18 Then
lvChannel.SelectedItem.ForeColor = vbYellow
lvPing.SelectedItem.ForeColor = vbYellow
End If
lvChannel.ListItems.add , , username
lvPing.ListItems.add , , Ping & "ms"


some1 help me with this code.
Title: Re: SelectedItem.ForeColor?
Post by: R.a.B.B.i.T on November 05, 2004, 04:38 PM
I do this in my bots also.  Use FindItem() to grab the index of the username you want to change, then use ListItems() to set its forecolor.
Title: Re: SelectedItem.ForeColor?
Post by: Yegg on November 05, 2004, 04:45 PM
hmm, im tryign 2 do this, but im not sur exactly how i set the code up. can u giv a small example?
Title: Re: SelectedItem.ForeColor?
Post by: phvckmeh on November 05, 2004, 05:42 PM
lvChannel.ListItems(lvChannel.FindItem(Username).Index).ForeColor = vbCyan
Title: Re: SelectedItem.ForeColor?
Post by: Yegg on November 05, 2004, 06:34 PM
I now have the following code and it does not work.

If flags = 2 Or flags = 18 Then
lvChannel.ListItems(lvChannel.FindItem(username).index).ForeColor = vbWhite
End If

Title: Re: SelectedItem.ForeColor?
Post by: R.a.B.B.i.T on November 05, 2004, 06:55 PM
Ahh, I was going off the top of my head and was wrong:Form1.lvChannel.FindItem(UserName).ForeColor = vWhite
Title: Re: SelectedItem.ForeColor?
Post by: LivedKrad on November 06, 2004, 11:43 AM
Yegg, in the event for OnUser, whatever that may be, you'll have to find your own username first.

If Username = "Yegg" Then
Form1.lvChannel.FindItem(Username).ForeColor = vbCyan
End If


Or, so the code will be faster because 1 check will only be true...

Select Case Flags
Case 2
   Form1.lvChannel.FindItem(Username).ForeColor = vbWhite
Case 18
   Form1.lvChannel.FindItem(Username).ForeColor = vbWhite
Case Else
   Form1.lvChannel.FindItem(Username).ForeColor = vbYellow
End Select


Now, we're assuming here that all Usernames have been assigned yellow or white, and now we can find our own.


If Username = "Yegg" Then
Form1.lvChannel.FindItem(Username).ForeColor = vbCyan
End if

This all should work, if not, then reply back.