【问题标题】:C#: How do you control the current item index that displays in a ComboBox?C#:如何控制 ComboBox 中显示的当前项索引?
【发布时间】:2009-01-19 20:53:57
【问题描述】:

我已经在组合框中设置了一个项目列表,但是当我调试应用程序时,我必须从下拉列表中选择一个项目才能默认显示一个项目。有财产吗?您可以设置组合框 itemindex 始终从 0 开始,这意味着应用程序启动时列表中的第一项?

【问题讨论】:

    标签: c#


    【解决方案1】:
    this.comboBox1.SelectedIndex = 0;
    

    【讨论】:

      【解决方案2】:

      你会想要使用 SelectedIndex 属性。

      SelectedItem 属性只能读取。 使用 SelectedText 和 SelectedValue 属性将更改文本和值,而不是选择哪个

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-11-12
        • 1970-01-01
        • 2011-04-16
        • 1970-01-01
        • 2013-04-07
        • 1970-01-01
        • 1970-01-01
        • 2011-01-13
        相关资源
        最近更新 更多