选定项目中的可见和不可见组合框 [英] visible and invisible comboboxes from select items

查看:91
本文介绍了选定项目中的可见和不可见组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是

i有一个combobox1控件和五个项目进入组合框控件。

i想要当我在combobox1控件内选择titem1时所以其他的combobox2应该是可见。与我选择item2时相同,那么combobox2应该是可见的,而combobox1应该是不可见的。

i已经尝试了,我的代码在下面,但问题是只有第一项只有可见而其他只有可见

请不要指导我





My problem is
i have one combobox1 control and inside the five items into the combobox control.
i want when i selec titem1 inside the combobox1 control so other combobox2 should be visible. same as when i select item2 then combobox2 should be visible and combobox1 should be invisible.
i have tried and my codes are below but problem is only first item does visible only and other does
not please guide me


private void courtnamelist_SelectedIndexChanged(object sender, EventArgs e)
      {

           districtcourtlist.Visible = false;
           supremecourtlist.Visible = false;
           heighcourtlist.Visible = false;
           nationlgreentribunallict.Visible = false;
           labourcourtlist.Visible = false;


         int[] arr = new int[10];
         int selectinsexval = courtnamelist.SelectedIndex;

         if (selectinsexval == arr[0])
         {
             supremecourtlist.Visible = true;
             districtcourtlist.Visible = false;

             heighcourtlist.Visible = false;
             nationlgreentribunallict.Visible = false;
             labourcourtlist.Visible = false;

         }
         else if (selectinsexval == arr[1])
         {
             heighcourtlist.Visible = true;
             supremecourtlist.Visible = true;
             districtcourtlist.Visible = false;


             nationlgreentribunallict.Visible = false;
             labourcourtlist.Visible = false;
          }
         else if (selectinsexval == arr[2])
         {
             heighcourtlist.Visible = true;
             supremecourtlist.Visible = true;
             districtcourtlist.Visible = false;


             nationlgreentribunallict.Visible = false;
             labourcourtlist.Visible = false;
         }


     }

推荐答案

您将'selectinsexval'与未分配(新)整数数组的内容。

在此数组中,所有未分配的元素都是== 0.

如果你选择你的第一个项目你的Combobox它有索引== 0。所以它有效。

下一个项目有索引== 1 ...



你明白我的意思了吗??

或许与常量进行比较......
You compare your 'selectinsexval' with the contents of a not assigned (new) Integer-Array.
Inside this Array, all elements which are not assigned are ==0.
If you select your first Item inside your Combobox it has the Index==0. So it works.
The next Item has Index==1 ...

Did you get what I mean ...?
Perhaps comparewith constants ...


这篇关于选定项目中的可见和不可见组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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