• Welcome to Valhalla Legends Archive.
 

Vb -> ListView Question

Started by gotcha_ass, February 25, 2003, 07:07 PM

Previous topic - Next topic

gotcha_ass

Ok Im using a listview to do the members in a channel and their icon. My problem is when someone leaves the channel, the list doesnt bump up to fill in that person empty space. It just leaves an empty space until the next user joins and fills it in. Is there any code that will automatically shift everyone up when someone leaves the channel?

Grok

#1
Use Remove method of the ListItems collection in the ListView.  The parameter is Key.

ListView1.ListItems.Remove ItemX.Key

Noodlez

#2
listview1.refresh after you remove someone

Mesiah / haiseM

#3
are you sure its a listview, ive known listbox's to do that, but never on my listview...

and yes make sure you remove the item by its index, you can use finditem to retreive this, or store it in a subitem(pointless, but would work all the same)
]HighBrow Innovations
Coming soon...

AIM Online Status: 

gotcha_ass

#4
I think it is the refresh that its missing

Mesiah / haiseM

#5
no because it automatically refreshes in a way, and if you refresh the list every time you do that, if you get a floodbot or something, your bot is gonna freeze up rendering it completely helpless, even after the flood bots leave, so i wouldnt reccoment it..
]HighBrow Innovations
Coming soon...

AIM Online Status: 

haZe

#6
You don't even really have to worry about floodbots anymore on account of how strictly battle.net is enforcing their rules on rejoins/reconnects because of all the complaints on LoRd]ZeR0['s gay ass floodbot. :-/

Mesiah / haiseM

#7
no offense, but any smart programmer can sit down and make the best flood bot ever seen, and get away with it being faster than ones that already exist.
]HighBrow Innovations
Coming soon...

AIM Online Status: 

Zakath

#8
The only people who are interested in things like floodbots (whose entire purpose is to annoy other people) are almost by definition idiots...
Quote from: iago on February 02, 2005, 03:07 PM
Yes, you can't have everybody...contributing to the main source repository.  That would be stupid and create chaos.

Opensource projects...would be dumb.

Camel

#9
Quoteno because it automatically refreshes in a way, and if you refresh the list every time you do that, if you get a floodbot or something, your bot is gonna freeze up rendering it completely helpless, even after the flood bots leave, so i wouldnt reccoment it..

make a timer and set its interval to like 10ms or something small like that. every time you you want to refresh the listview, do tmrwhatever.enabled = false and then tmrwhatever.enabled = true. that way the timer wont execute until 10ms after the "last" time you modify the list. well, vb timers suck and are inaccurate, but it works ;)

gotcha_ass

Ahhh! Its still doing it. No one else has ever had this problem? Like when the second person in the channel leaves, his places stays blank and then the next person to join fills it, I mean I can live w/ it but its annoying.

*And yes its a listview heres the code that does it, I copied it strait off AssBot(I gave it credits to)

Public Sub DelNick(ByVal strKey$)
    Dim i&
    
    If frmMain.ChannelUsers.ListItems.Count > 1 Then
        For i = 1 To frmMain.ChannelUsers.ListItems.Count
            If Left(frmMain.ChannelUsers.ListItems(i).Key, InStr(1, frmMain.ChannelUsers.ListItems(i).Key, "&") - 1) = strKey Then
                frmMain.ChannelUsers.ListItems.Remove i
                frmMain.ChannelUsers.Refresh
                Exit For
            End If
        Next i
    Else
        If Left(frmMain.ChannelUsers.ListItems(1).Key, InStr(1, frmMain.ChannelUsers.ListItems(1).Key, "&") - 1) = strKey Then
            frmMain.ChannelUsers.ListItems.Remove 1
            frmMain.ChannelUsers.Refresh
        End If
    End If
End Sub

Camel

#11
Quoteyou can use finditem to retreive this

Mesiah / haiseM

#12
let me see if i can modify this a bit for ya

Public Sub DelNick(ByVal strName$)
    
    frmmain.channelusers.listitems.remove frmmain.channelusers.finditem(strname$)

End Sub

thats all you really need to do, simply.. if you want to add things like extended support for duplicated names, im sure you can do it, but initially this is all u need.
]HighBrow Innovations
Coming soon...

AIM Online Status: 

gotcha_ass

#13
Thanks Messiah, I dont know why they put so much code into the AssBot, when all it required was that. Hopefully it'll work I'll go try it now.

Spht

#14
Well if you actually read the function you'd see what he is searching for in the list view. Ickis has his reason for doing such things.

It is more accurate to identify users in channel by unique keys, instead of by their name. Seeing as things like two people in the channel having the same name occurs sometimes, identifying user's by their name would not work out very well at all in this case.