如何找出组合框内是否有一些项目? [英] How to find out if combobox have some items inside?
本文介绍了如何找出组合框内是否有一些项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 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");
}
推荐答案
双击表单中的按钮并将此代码插入到单击事件处理程序中:`
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屋!
查看全文