这是一个桌面应用程序。如何将事件添加到事件列表控件?以下代码无效
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 :(得分: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);
}