如何在获胜形式的组合框中隐藏特定项目 [英] How to hide specific item from a combo box in win forms

查看:24
本文介绍了如何在获胜形式的组合框中隐藏特定项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从组合框中隐藏特定数量的项目.下面的代码将隐藏所有项目.我找不到执行此操作的方法

How can I hide specific number of items from a combo box. Code below will hide all the items instead. I couldn't find a way to perform this

string taskSelection = taskSelectionComboBox.Text;
string stateOfChild = stateOfChildComboBox.Text;
if (stateOfChild == "Awake")
{
    taskSelectionComboBox.Hide();
}

推荐答案

您需要存储您想要的项目,然后使用 remove 方法删除它们.您可以使用 add 使它们恢复原状.

you need to store the items you want then use remove method to delete them. you can use add to make them back.

// keep the items in a list
List<string> list = new List<string>();
list.Add("Awake");
// remove them from combobox
comboBox1.Items.Remove("Awake");
// if you want to add them again.
comboBox1.Items.Add(list[0]);

这篇关于如何在获胜形式的组合框中隐藏特定项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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