如何根据DropDown1选择显示DropDown2中的值 [英] How to display the value in DropDown2 based on the DropDown1 Selection

查看:63
本文介绍了如何根据DropDown1选择显示DropDown2中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想在DropDown2中显示值,但必须根据Dropdown1中的选项显示。



例如:DropDown1包含2个值(A,B)如果我选择A然后Dropdown2必须显示1A 2A



if(DropDownList1.SelectedItem) .Text.Equals(A))

{

DropDownList2.Items.Add(new ListItem(1A,0));

DropDownList2.Items.Add(new ListItem(2A,1));



}

else if (DropDownList1.SelectedItem.Text.Equals(B))

{

DropDownList2.Items.Add(new ListItem(1B,0));

DropDownList2.Items.Add(new ListItem(2B,1));

}



我已经检查了下拉列表中的Autopushback = true。请帮助我,并提前感谢!!!

Hi,

I want to display the values in DropDown2 but it have to display based on the selection in Dropdown1.

Eg: DropDown1 contains 2 values(A,B) if i choose A then Dropdown2 have to display 1A 2A

if (DropDownList1.SelectedItem.Text.Equals("A"))
{
DropDownList2.Items.Add(new ListItem("1A", "0"));
DropDownList2.Items.Add(new ListItem("2A", "1"));

}
else if(DropDownList1.SelectedItem.Text.Equals("B"))
{
DropDownList2.Items.Add(new ListItem("1B", "0"));
DropDownList2.Items.Add(new ListItem("2B", "1"));
}

I have check the Autopushback= true for both the dropdown. Please help me out on this and thanks in advance!!!

推荐答案

CComboBox m_cComboSateName1,m_cComboSateName2;

CString CStemp;

m_cComboSateName1.GetWindowTextW(CStemp);



if(CStemp.compare(A)== 0)

{

m_cComboSateName2.AddString(1A);

m_cComboSateName2.AddString(2A);

}

否则(CStemp.compare(B)== 0))

{

m_cComboSateName2.AddString(1B);

m_cComboSateName2.AddString(2B);

}





//完全是这样的,但是请检查比较函数或任何其他语法错误。在字符串比较的情况下检查你是否使用unicode或multi
CComboBox m_cComboSateName1,m_cComboSateName2;
CString CStemp;
m_cComboSateName1.GetWindowTextW(CStemp);

if (CStemp.compare("A")==0)
{
m_cComboSateName2.AddString("1A");
m_cComboSateName2.AddString("2A");
}
else if(CStemp.compare("B")==0))
{
m_cComboSateName2.AddString("1B");
m_cComboSateName2.AddString("2B");
}


//Something exactly like this,But please check the compare function or any other syntax mistake.Also check if u r using unicode or multi in case of string comparasion


这篇关于如何根据DropDown1选择显示DropDown2中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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