如何确定组合框内是否有物品? [英] How to find out if combobox have some items inside?

查看:76
本文介绍了如何确定组合框内是否有物品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中有一个简单的winforms应用程序,它具有两个控件: combobox1 button 。当然,分别是 ComboBox Button 。我想找出 combobox1 ...

I have simple winforms application in C# which has two controls: combobox1 and button. Of course, a ComboBox and Button respectively. I would like to find out if there are any items in combobox1...

中是否有任何项目,但是尝试了它只会告诉我是否存在选定的项目:

I have tried this, but it only tells me if there is a selected item:

if (combobox1.Text != ""))
{
    MessageBox.Show("Combo is not empty");
}


推荐答案

在表单,然后将此代码插入click事件处理程序内:`

Double click on your button in the Form and insert this code inside the click event handler : `

        //this code should work
        if (comboBox1.Items.Count == 0)
        {
            MessageBox.Show("Your combo is empty");
        }

   `

这篇关于如何确定组合框内是否有物品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆