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

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

问题描述

我无法弄清楚如何将项目添加到 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 的内部(默认)数据结构是 列表框项.

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

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

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