需要帮助编写组合框 [英] Need help in coding of combo box

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

问题描述

大家好



我想要一个像



的条件 if (comboBox1.SelectedText =   Graduation
comboBox2.Items。添加 BA);





像这样我有5个comboBox1选项。请告诉我如何编写代码..

解决方案

  if (comboBox1.SelectedText =  毕业
comboBox2.Items.Add( BA);
else if (comboBox1.SelectedText == 性别
comboBox2.Items.Add( M / F);
else if (comboBox1.SelectedText ==
comboBox2.Items.Add( 数学/历史);
// 依此类推......


  if (comboBox1.SelectedText ==   10
comboBox2.Enabled = false;

else if (comboBox1.SelectedText == 10 + 2
comboBox2.Enabled = false;

else if (comboBox1.SelectedText == 毕业
{
comboBox2.Items。 Add BA);
comboBox2.Items。添加 BBM );
comboBox2.Items。添加 BCA );
}

else if (comboBox1.SelectedText == < span class =code-string>
毕业后
{
comboBox2.Items。添加 MA);
comboBox2.Items。添加 MBA );
comboBox2.Items。添加 MCA );
}

else if (comboBox1.SelectedText == < span class =code-string>
博士
{
comboBox2.Items。添加 M.tech);
comboBox2.Items。添加 P .hd);
}


它的工作原理:

  private   void  comboBox1_SelectedIndexChanged( object  sender,EventArgs e)
{
if 毕业 == comboBox1.SelectedItem.ToString())
{
comboBox2.Items.Add( BBM);
comboBox2.Items.Add( BCA);
}

if Post-Graduation == comboBox1.SelectedItem.ToString())
{
comboBox2.Items.Clear();

comboBox2.Items.Add( MA);
comboBox2.Items.Add( MBA);
comboBox2.Items.Add( MCA);
}
}


Hi all

I want a condition like

if(comboBox1.SelectedText = "Graduation")
                comboBox2.Items.Add("BA");



like this i have 5 options for comboBox1..Please tell me how to write the code..

解决方案

if(comboBox1.SelectedText = "Graduation")
                comboBox2.Items.Add("BA");
else if(comboBox1.SelectedText== "Gender")
                comboBox2.Items.Add("M/F");
else if(comboBox1.SelectedText== "Class")
                comboBox2.Items.Add("Maths/History");
// and so on...


if (comboBox1.SelectedText == "10")
                    comboBox2.Enabled = false;

             else if(comboBox1.SelectedText == "10+2")
                    comboBox2.Enabled = false;

            else  if(comboBox1.SelectedText == "Graduation")
{
                    comboBox2.Items.Add("BA");
                    comboBox2.Items.Add("BBM");
                    comboBox2.Items.Add("BCA");
}

            else if(comboBox1.SelectedText == "Post-Graduation")
{
                    comboBox2.Items.Add("MA");
                    comboBox2.Items.Add("MBA");
                    comboBox2.Items.Add("MCA");
}

            else if(comboBox1.SelectedText == "Doctorate")
{
                    comboBox2.Items.Add("M.tech");
                    comboBox2.Items.Add("P.hd");
}


Its workin :

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
      {
          if ("Graduation" == comboBox1.SelectedItem.ToString())
          {
              comboBox2.Items.Add("BBM");
              comboBox2.Items.Add("BCA");
          }

          if ("Post-Graduation" == comboBox1.SelectedItem.ToString())
          {
              comboBox2.Items.Clear();

              comboBox2.Items.Add("MA");
              comboBox2.Items.Add("MBA");
              comboBox2.Items.Add("MCA");
          }
      }


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

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