You are here: MessengerYouLike.IMSDK > IMSDK Reference > IMSDK Namespace > Classes > IMClient Class > IMClient Events > IMClient.OnFriendsListUpdated Event
MessengerYouLike
IMClient.OnFriendsListUpdated Event

When Ever any Property of Contacts is Updated this event is fired

C#
public event OnFriendsListUpdated;
Visual Basic
Public Event OnFriendsListUpdated(ByVal DateTime As DateTime)
Return Values 
Description 
ByVal DateTime As DateTime 
DateTime when this event is fired this useful to track when was last Update 

This is most important event.This event fires when ever any thing in the IMClient is updated like if a user is removed or a friend is added the respective events will fire but this event will also fire telling the user that some thing has changed 

when ever this event fires the developer should create a function/sub that gets all the properties of the friends/contacts and update the UI 

make sure when you update the UI it is Done on a sperate thread take a look at the example and Sample Program

[Visual Basic]
 Private Sub MC_OnFriendsListUpdated(ByVal DateTime As String) Handles MC.OnFriendsListUpdated
        loadlv()
    End Sub
 
  Delegate Function DlgLoad() As Boolean
 
   Private Sub loadlv()
        Dim oDlg As DlgLoad = New DlgLoad(AddressOf loadlv2)
        Me.BeginInvoke(oDlg)
    End Sub
 
 
 
Function loadlv2() As Boolean
        FriendsTV.Nodes.Clear()
 
 
 
        For i As Integer = 0 To MCUser.Groups.Count - 1
            Dim nd2 As New TreeNode
            With nd2
 
                .ToolTipText = "Online = " & MCUser.Groups.Item(i).TotalOnlineFriends.ToString & _
               "Offline = " & MCUser.Groups.Item(i).TotalOfflineFriends.ToString & _
               "Busy = " & MCUser.Groups.Item(i).TotalBusyFriends.ToString & _
               "unauthorized = " & MCUser.Groups.Item(i).TotalUnAuthFriends
 
                .Text = MCUser.Groups.Item(i).GroupName & " ( " & MCUser.Groups.Item(i).TotalOnlineFriends.ToString & " / " & MCUser.Groups.Item(i).TotalFriends.ToString & " )"
                .Tag = MCUser.Groups.Item(i).UID
            End With
 
            FriendsTV.Nodes.Add(nd2)
 
            Dim fr As IMSDK.Friends = MCUser.Groups.Item(i).Friends
 
            For j As Integer = 0 To fr.Count - 1
                Dim nd3 As New TreeNode
 
                With nd3
                    .Text = fr.Item(j).FriendUsername & " - " & fr.Item(j).FriendStatus.ToString & " - " & fr.Item(j).FriendAuthStatus.ToString & " - " & fr.Item(j).Blocked.ToString & " - " & fr.Item(j).AmIBlocked.ToString
                    .Tag = fr.Item(j).FriendUsername
                End With
 
                FriendsTV.Nodes.Item(FriendsTV.Nodes.IndexOf(nd2)).Nodes.Add(nd3)
 
            Next j
 
        Next i
 
        FriendsTV.ExpandAll()
        FriendsTV.Visible = True
 
    End Function
 
Copyright (c) 2007. All rights reserved.