visual studio C#组合框活动

时间:2017-04-09 05:58:42

标签: c# events combobox selectedindexchanged

   private void droplesson_SelectedIndexChanged(object sender, EventArgs e)
    {
        if(e.Equals("LESSON1"));
        reload("LESSON1.txt");
        if(e.Equals("LESSSON2"));
        reload("LESSON2.txt");
        if(e.Equals("LESSON3"));
        reload("LESSON3.txt");
        if(e.Equals("LESSON4"));
        reload("LESSON4.txt");
        if (e.Equals("LESSON5"));
        reload("LESSON5.txt");

    }

以上代码无效。我想更改下拉菜单,以便在我选择特定课程时重新加载该课程。enter image description here

1 个答案:

答案 0 :(得分:0)

您添加了';'在每一行的末尾,包括' if'所有的重新加载'电话被执行了......

这是您的代码的外观:

private void droplesson_SelectedIndexChanged(object sender, EventArgs e)
{
    if(e.Equals("LESSON1"))
        reload("LESSON1.txt");
    if(e.Equals("LESSSON2"))
        reload("LESSON2.txt");
    if(e.Equals("LESSON3"))
        reload("LESSON3.txt");
    if(e.Equals("LESSON4"))
        reload("LESSON4.txt");
    if (e.Equals("LESSON5"))
        reload("LESSON5.txt");
}