c#中combobox的一个用法

来源:百度知道 编辑:UC知道 时间:2024/05/20 23:16:35
我的combobox控件下面有几个选项,我想要写这样一个语句该怎样实现?

if(选中的是第n对象)
{
//其他代码
}

这当中,“选中的是第n对象”该怎么表达?在线等~~

我刚才弄了弄你可以去试试,你先新建一个工程,然后在窗体里加一个combobox和一label然后按照我下面的做,我觉得你应该看的懂吧,实在不懂可以加我QQ:1200607

private void Form1_Load(object sender, EventArgs e)
{
this.comboBox1.Items.Add("a");
this.comboBox1.Items.Add("b");
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.comboBox1.Text == "a")
{
this.label1.Text = "1";
}
else if (this.comboBox1.Text == "b")
{
this.label1.Text = "2";
}

}

string a = ;
if(combobox.selectvalue == value)
{
a = value
}

swith(a)
{
case a:
break;
base b:
break
}

就是这个逻辑