我怎么可能一个项目添加到ListBox? [英] How might I add an item to a ListBox?
本文介绍了我怎么可能一个项目添加到ListBox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法搞清楚如何项添加到<一个href=\"http://msdn.microsoft.com/en-us/library/system.windows.controls.listbox.aspx\"><$c$c>ListBox$c$c>在的WinForms。
我想:
list.DisplayMember =族;
list.ValueMember = sifOsoba;
我如何将项目添加到列表中与 INT
值( ValueMember
)和一些全文( 的DisplayMember
)?
list.Items.add(?)
我不能使用 ListBoxItem的
。为什么呢?
解决方案
list.Items.add(新ListBoxItem的(名,价值));
内部(默认)数据ListBox的结构是<一个href=\"http://msdn.microsoft.com/en-us/library/system.windows.controls.listboxitem.aspx\">ListBoxItem.
I'm having trouble figuring out how to add items to a ListBox
in WinForms.
I'm trying:
list.DisplayMember = "clan";
list.ValueMember = sifOsoba;
How can I add items to the list with an int
value (ValueMember
) and some text (for the DisplayMember
)?
list.Items.add(?)
I can't use ListBoxItem
. Why?
解决方案
list.Items.add(new ListBoxItem("name", "value"));
The internal (default) data structure of the ListBox is the ListBoxItem.
这篇关于我怎么可能一个项目添加到ListBox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文