2009-12-31 72 views
1

这是一个桌面应用程序。如何将事件添加到事件列表控件?下面的代码是不工作vs2008 c#:将事件添加到facebook的winform应用程序的eventlist控件

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


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

错误信息

错误1无法隐式转换类型“System.Collections.Generic.IList”到“System.Collections.ObjectModel.Collection”。 C:\ Documents and Settings \ ZULFIQAR SYED \ Local Settings \ Application Data \ Temporary Projects \ WindowsFormsApplication1 \ Form1.cs 42 41 WindowsFormsApplication1

+0

您确认Facebook服务是否确实返回IList <>? – 2009-12-31 23:57:38

回答

0

您的意思是受保护的Events成员(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); 
    } 
相关问题