Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can somebody please guide me how to generate an event if the date in list box is changed

I am filling the list with all the online users on skype using sky4com library. If a new user comes online i want to update my form and display the new online user too in the listbox. Thanks in advance for any help.

C#
using SKYPE4COMLib;
using System.Runtime.InteropServices;

 List<string> online_users = new List<string>();
 IEnumerable<SKYPE4COMLib.User> users;


Update_listbox();
            listBox1.DataSource = online_users;



        public void Update_listbox()
        {
            users = skype.Friends.OfType<SKYPE4COMLib.User>();

            users
                .Where(u => u.OnlineStatus == TOnlineStatus.olsOnline)
                .OrderBy(u => u.Handle)
                .ToList()
                .ForEach(u =>  online_users.Add(u.Handle));
            Update();
           
        }
Posted
Updated 11-Jul-13 0:17am
v2

 
Share this answer
 
The event should not get generated by the ListBox but some underlying logic. Bind the ListBox to a BindingList<t>[^] instead of a List<t>. Any changes to the list will get displayed without the Update() call.

However, you still need the method known as Update_listbox(). Just name it according to its purpose: changing your bound online users list.

And then again, you need to call it. How is it called now? Does the skype4com library provide an event?

As a last resort, there's always a Timer (or this, or that) to poll the data.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900