有两个组合框工作 [英] working with two combo boxes

查看:129
本文介绍了有两个组合框工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时通讯使用C#.NET Windows窗体应用程序。我有两个组合框A和B都。我一个pouplated一些值。现在,如果我选择从任何一个值,我应该能够填充B,其中A,除了所选项目的所有项目。


解决方案

也许你想这样的:

 的for(int i = 0; I< comboBox1.Items.Count;我++) 
{
如果((comboBox1.SelectedIndex)= I!)
{
comboBox2.Items.Add(comboBox2.Items [I]);
}
}

您之前添加新项目

Im using c# .net windows form application. I have two comboboxes A and B .I have pouplated A with some values. Now if i select any one value from A, I should be able to populate B with all the items of A except the selected item .

解决方案

maybe you want this :

    for (int i = 0; i < comboBox1.Items.Count;i++)
    {
        if ((comboBox1.SelectedIndex)!=i)
        {
            comboBox2.Items.Add(comboBox2.Items[i]);
        }
    }

you have to clear comboBox2 before adding new items

这篇关于有两个组合框工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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