• Welcome to Valhalla Legends Archive.
 

SelectedItem.ForeColor?

Started by Yegg, November 05, 2004, 04:35 PM

Previous topic - Next topic

Yegg

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.

R.a.B.B.i.T

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.

Yegg

#2
hmm, im tryign 2 do this, but im not sur exactly how i set the code up. can u giv a small example?

phvckmeh

lvChannel.ListItems(lvChannel.FindItem(Username).Index).ForeColor = vbCyan

Yegg

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


R.a.B.B.i.T

Ahh, I was going off the top of my head and was wrong:Form1.lvChannel.FindItem(UserName).ForeColor = vWhite

LivedKrad

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.