开发者

ToolStripDropDownButton, how to remove all DropDownItems?

开发者 https://www.devze.com 2023-01-28 15:53 出处:网络
How to remove all DropDownItems from a ToolStripDropDownButton, if i开发者_运维技巧ts propery is read only?Use the Clear method:

How to remove all DropDownItems from a ToolStripDropDownButton, if i开发者_运维技巧ts propery is read only?


Use the Clear method:

toolStripDropDownButton1.DropDownItems.Clear();


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消