如何在C#和WinForms中将项目添加到列表框? [英] How can I add an item to a ListBox in C# and WinForms?

查看:58
本文介绍了如何在C#和WinForms中将项目添加到列表框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在弄清楚如何将项目添加到在WinForms中是 ListBox

I'm having trouble figuring out how to add items to a ListBox in WinForms.

我尝试过:

list.DisplayMember = "clan";
list.ValueMember = sifOsoba;

如何将 ValueMember 添加到列表中 int 的值和 DisplayMember 的一些文本?

How can I add ValueMember to the list with an int value and some text for the DisplayMember?

list.Items.add(?)

顺便说一句。出于任何原因,我都无法使用 ListBoxItem

推荐答案

list.Items.add(new ListBoxItem("name", "value"));

ListBox的内部(默认)数据结构为 ListBoxItem

The internal (default) data structure of the ListBox is the ListBoxItem.

这篇关于如何在C#和WinForms中将项目添加到列表框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆