ToolStripDropDownButton,如何删除所有DropDownItems?

发布于 2024-10-05 14:05:33 字数 89 浏览 0 评论 0原文

如果 ToolStripDropDownButton 的属性是只读的,如何从 ToolStripDropDownButton 中删除所有 DropDownItem?

How to remove all DropDownItems from a ToolStripDropDownButton, if its propery is read only?

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

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

发布评论

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

评论(2

天荒地未老 2024-10-12 14:05:33

使用清除方法:

toolStripDropDownButton1.DropDownItems.Clear();

Use the Clear method:

toolStripDropDownButton1.DropDownItems.Clear();
绝不服输 2024-10-12 14:05:33

DropDownItems 属性是一个集合。请参阅

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

因此,您可以使用Remove 和RemoveAt 来删除项目,最好使用for 循环。

此外,从某种意义上说,该属性是只读的,无法使用运算符设置它,但可以修改集合的内容。

The DropDownItems property is a collection. See

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

Therefore, you can use Remove and RemoveAt to remove items, preferably using a for loop.

In addition, the property is read only in a sense that you can't set it using an operator, but you can modify the contents of the collection.

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