【问题标题】:How to display blank item in the combobox?如何在组合框中显示空白项?
【发布时间】:2014-09-01 20:36:58
【问题描述】:

对于Combobox,我从System.Collections.ObjectModel.Collection 获取值列表。

我正在分配这样的值:

this.cmbSqlServer.DataSource = this.SqlInstancesCollection;

我不想在Combobox 中看到列表中的第一项,除非我选择了它。

如果没有选择任何内容,如何在Combobox 中显示空白字段?

【问题讨论】:

    标签: c# .net winforms c#-4.0 combobox


    【解决方案1】:

    如果我理解正确,您只需重置SelectedItem。只需将 SelectedIndex 设置为 -1。

    this.cmbSqlServer.DataSource = this.SqlInstancesCollection;
    this.cmbSqlServer.SelectedIndex = -1;
    

    【讨论】:

    • 非常感谢。工作正常。
    猜你喜欢
    • 2013-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-08
    • 1970-01-01
    • 2016-04-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多