简体   繁体   English

在 C# 组合框中设置空白文本

[英]Setting blank text in c# combo box

So I am using a combo box that the user is only allowed to choose a few options.所以我使用了一个组合框,用户只能选择几个选项。 I am working on user validation right now.我现在正在处理用户验证。 When you start the program the there is no text in the combo box.当您启动程序时,组合框中没有文本。 I want to be able to reset the combo box back to that default and make it blank when ever I need to.我希望能够将组合框重置为默认值,并在需要时将其设为空白。 I have been trying things such as comboBox1.Text = "";我一直在尝试诸如comboBox1.Text = "";东西comboBox1.Text = ""; and that was a no go.那是不行的。 I even tried doing comboBox1.Items.Clear();我什至尝试做comboBox1.Items.Clear(); Then re adding all the items back in again.然后重新添加所有项目。 Re adding the items wouldn't be an issue except one of the combo boxes is very lengthy.重新添加项目不会成为问题,除非其中一个组合框很长。

Is there a way to make a combo box returns to its default of being blank?有没有办法让组合框恢复到默认的空白?

用 :

ComboBox1.SelectedIndex = -1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM