如何禁用组合框? [英] How to disable combo box?
本文介绍了如何禁用组合框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的.net Windows应用程序中有三个组合框.在第一个组合框中,有两个选项,例如India和Foreign.如果我在第一个组合框中选择印度",则必须禁用第三个组合框.如果我在第一个组合框中选择外国",则第二个组合框中将不得不禁用.这是我的问题.请将编码发送给我.
Hi,
I have three combo box in my .net windows application.In 1st combo box i have two option like India and Foreign. If i select india in 1st combo box,the third combo box will have to disabled. if i choose foreign in 1st combo box ,the 2nd combo box will have to disabled. This is my question.Kindly send me the coding.
protected void combobox1_SelectedIndexChanged(object sender, EventArgs e)
{
if(combobox1.SelectVelue == "indian")
{
combobox3.Enable = false;
combobox2.Enable = true;
}
else if (combobox1.SelectVelue == "Foreign")
{
combobox3.Enable = true;
combobox2.Enable = False;
}
Else
{
combobox3.Enable = true;
combobox2.Enable = true;
}
}
该代码不起作用..所以请发送其他任何代码..
谢谢,
Viswanathan.M
This code is not work..So please send any other..
Thanks,
Viswanathan.M
推荐答案
switch (combo1.SelectedValue)
{
case "India" :
combo3.Enabled = false;
combo2.Enabled = true;
break;
case "Foreign" :
combo3.Enabled = true;
combo2.Enabled = false;
break;
default:
combo3.Enabled = true;
combo2.Enabled = true;
break;
}
This is easily found on Google.
您也可以使用if语句将该任务归档(因为您的问题是是否combobox1 value =="india",必须禁用第三个组合框)和(如果combobox1 value =="Foreign",则第二个组合框将被禁用)
您可以创建一个函数来保存并使用它,或者只需在IDE的设计器视图中双击组合框即可.
受保护的void combobox1_SelectedIndexChanged(对象发送者,EventArgs e)
{
if(combobox1.SelectVelue ==印度")
{
combobox3.Enable = false;
combobox2.Enable = true;
}
否则,如果(combobox1.SelectVelue ==外来")
{
combobox3.Enable = true;
combobox2.Enable = False;
}
其他
{
combobox3.Enable = true;
combobox2.Enable = true;
}
}
You as well archive this task using an if statement (Becasue your question is if combobox1 value == "india" the third combo box will have to disabled) and (If combobox1 value == "Foreign" 2nd combo box will have to disabled)
You can create a function to hold this and use it like this or just Double click the combo box from the designer view in your IDE
protected void combobox1_SelectedIndexChanged(object sender, EventArgs e)
{
if(combobox1.SelectVelue == "indian")
{
combobox3.Enable = false;
combobox2.Enable = true;
}
else if (combobox1.SelectVelue == "Foreign")
{
combobox3.Enable = true;
combobox2.Enable = False;
}
Else
{
combobox3.Enable = true;
combobox2.Enable = true;
}
}
这篇关于如何禁用组合框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文