我如何隐藏和返回组合框上的一些值 [英] how can i hide and return some values on combobox

查看:81
本文介绍了我如何隐藏和返回组合框上的一些值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hiiiii

如何在组合框上隐藏一些值,经过一些更改后,返回并恢复到这个组合框的正常值?

请帮助我。我有一个严重的问题

hiiiii
how can i hide some values on combobox and after some changes, return and come back to normal values of this combobox?
help me please. i have a serious problem

推荐答案

此代码演示了如何在WinForms ComboBox中添加和恢复第七项:
This code demonstrates adding, and restoring, the seventh Item in a WinForms ComboBox:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    if (comboBox1.Items.Contains("Item 7"))
    {
        comboBox1.Items.RemoveAt(6);
        // or use Remove("Item 7");
    }
    else
    {
        comboBox1.Items.Insert(6, "Item7");
    }
}

您需要存储并跟踪删除的项目,以及需要恢复时应插入的位置。



您应该阅读ComboBox.ObjectCollection类''包含','RemoveAt和'插入方法。

You'll have to store and keep track of which items you remove, and where they should be inserted when you need to restore them.

You should read the documentation on the ComboBox.ObjectCollection Class' 'Contains, 'RemoveAt, and 'Insert methods.

的文档。

这篇关于我如何隐藏和返回组合框上的一些值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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