【问题标题】:How to get the number of items in a combobox?如何获取组合框中的项目数?
【发布时间】:2010-10-20 14:10:24
【问题描述】:

如何获取组合框中列出的项目数?

【问题讨论】:

    标签: c# .net winforms combobox


    【解决方案1】:

    试试

    var count = comboBox.Items.Count;
    

    【讨论】:

      【解决方案2】:

      您应该引用Items 属性的Count

      myComboBox.Items.Count
      

      【讨论】:

        【解决方案3】:
        comboBox.Items.Count;
        

        不适合我。

        我用:

        comboBox->count();
        

        【讨论】:

        • 谢谢,我使用的是 Windows 窗体,而不是 WPF,我已在帖子中对此进行了说明。
        【解决方案4】:
        Variable_name_JComboBox.getComponentCount()
        

        【讨论】:

        • edit 在您的回答中说明其工作原理以及为什么它是问题中描述的问题的解决方案。见How to Answer
        猜你喜欢
        • 2014-07-24
        • 2019-10-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-01-13
        • 2018-12-22
        • 1970-01-01
        • 2017-04-28
        相关资源
        最近更新 更多