tags:

views:

75

answers:

1

This is a desktop application. How do I add events to the event list control? The following code is not working

    IList<user> friends = facebookService1.Friends.GetUserObjects();
    IList<facebookevent> events = facebookService1.Events.Get();


    friendList1.Friends = friends;
    eventList1.FacebookEvents = events;

error message

Error 1 Cannot implicitly convert type 'System.Collections.Generic.IList' to 'System.Collections.ObjectModel.Collection'. An explicit conversion exists (are you missing a cast?) C:\Documents and Settings\ZULFIQAR SYED\Local Settings\Application Data\Temporary Projects\WindowsFormsApplication1\Form1.cs 42 41 WindowsFormsApplication1

A: 

Do you mean the protected Events member (EventHandlerList)?

    private static readonly object MyEventKey = new object();
    public event EventHandler MyEvent
    {
        add {Events.AddHandler(MyEventKey, value);}
        remove {Events.RemoveHandler(MyEventKey, value);}
    }
    protected virtual void OnMyEvent()
    {
        EventHandler handler = (EventHandler)Events[MyEventKey];
        if (handler != null) handler(this, EventArgs.Empty);
    }
Marc Gravell