C# 清除选择框并动态构建它 - Windows 窗体应用程序

发布于 2024-10-08 13:10:08 字数 88 浏览 0 评论 0原文

如何在C#(Windows窗体应用程序)中清除选择框中的所有选项? 有什么简单的事情或者代码需要循环所有项目吗?

如何动态添加一个选项到这个选择框?

How to clear all the options in a select box in C# (Windows form application)?
Is there something easy or does the code need to loop over all the items?

How to dynamically add an option to this select box?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一袭白衣梦中忆 2024-10-15 13:10:08

调用 Items 属性上的 Clear() 方法

listControl.Items.Clear();

这适用于 ListBox组合框

http://msdn.microsoft.com/en-us/library/system.windows.forms.listcontrol.aspx

call the Clear() method on the Items Property

listControl.Items.Clear();

This will work for a ListBox or a ComboBox

http://msdn.microsoft.com/en-us/library/system.windows.forms.listcontrol.aspx

孤独陪着我 2024-10-15 13:10:08

如果它是 Windows 窗体 ListBox 控件,您可以使用 ListBox.Items.Clear()

If it's a Windows Forms ListBox control you can use ListBox.Items.Clear()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文