开发者

C# clear selectbox and build it dynamically - Windows form application

开发者 https://www.devze.com 2023-01-31 16:19 出处:网络
How to clear all the options in a select box in C# (Windo开发者_JAVA百科ws form application)? Is there something easy or does the code need to loop over all the items?

How to clear all the options in a select box in C# (Windo开发者_JAVA百科ws 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?


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


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

0

精彩评论

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