列表框事件生成器 [英] listbox event generator
本文介绍了列表框事件生成器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果列表框中的日期发生变化,有人可以指导我如何生成事件
我正在使用Skype上的所有在线用户填写列表sky4com库。如果新用户上线,我想更新我的表单并在列表框中显示新的在线用户。提前感谢您的帮助。
使用 SKYPE4COMLib;
使用 System.Runtime.InteropServices;
List< string> online_users = new 列表< string>();
IEnumerable< SKYPE4COMLib.User>用户;
Update_listbox();
listBox1.DataSource = online_users;
public void Update_listbox()
{
users = skype.Friends.OfType< SKYPE4COMLib.User>();
用户
。其中(u = > u.OnlineStatus == TOnlineStatus.olsOnline)
.OrderBy( u = > u.Handle)
.ToList()
.ForEach(u = > ; online_users.Add(u.Handle));
Update();
}
解决方案
数据绑定列表框
listbox refresh
事件不应该由ListBox生成,而是由一些底层逻辑生成。将ListBox绑定到 BindingList< t> [ ^ ]而不是List< t>。如果没有Update()调用,将显示对列表的任何更改。
但是,您仍然需要名为Update_listbox()的方法。只需根据其目的命名:更改绑定的在线用户列表。
再次,您需要调用它。现在怎么称呼? skype4com库是否提供了一个活动?
作为最后的手段,总有一个Timer (或 this 或那)轮询数据。
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.
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();
}
解决方案
databind listbox
listbox refresh
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.
这篇关于列表框事件生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文