我可以将语言列表链接到单选按钮吗?

时间:2019-04-29 17:17:53

标签: c# radio-button

我正在设计一个记忆游戏,我需要使用来自不同语言的单词而不是图标来玩游戏。为此,我需要从3组中选择2种语言。我创建了2个容器,每个容器具有3个选项,如果选中其中一个,则取消相反的选项。现在,我想将我创建的语言列表链接到单选按钮,以便当用户选择单选按钮时,将自动生成带有该语言的列表。有人可以帮我吗?

我尝试创建多个if语句,尝试将列表链接到单选按钮,但这给我一个错误

这是我用来创建3种语言列表的代码。

  

public frm_Edit_Language(){                  InitializeComponent();

                 languages.Add(new Languages());//English
                 languages.Add(new Languages());//Italian
                 languages.Add(new Languages());//French

                       languages[0].name = "English";
                       languages[1].name = "Italian";
                       languages[2].name = "French";

                          languages[0].Words.Add("Hello");
                          languages[0].Words.Add("Bye");
                          languages[0].Words.Add("Cat");
                          languages[0].Words.Add("Good Morning");
                          languages[0].Words.Add("Dog");
                          languages[0].Words.Add("Summer");
                          languages[0].Words.Add("Winter");
                          languages[0].Words.Add("Car");
                          languages[0].Words.Add("How are you?");
                          languages[0].Words.Add("Because");
                          languages[0].Words.Add("Good night");
                          languages[0].Words.Add("Thank you");
                          languages[0].Words.Add("My name is..");
                          languages[0].Words.Add("i live in..");
                          languages[0].Words.Add("boy");
                          languages[0].Words.Add("girl");
                          languages[0].Words.Add("pencil");
                          languages[0].Words.Add("Man");
                          languages[0].Words.Add("Woman");
                          languages[0].Words.Add("friend");
                          languages[0].Words.Add("Good luck!");
                          languages[0].Words.Add("Hot");
                          languages[0].Words.Add("Cold");
                          languages[0].Words.Add("How old are you?");
                          languages[0].Words.Add("What is your name?");
                          languages[0].Words.Add("Plane");

                          languages[1].Words.Add("Salve");
                          languages[1].Words.Add("Ciao");
                          languages[1].Words.Add("Gatto");
                          languages[1].Words.Add("Buongiorno");
                          languages[1].Words.Add("Cane");
                          languages[1].Words.Add("Estate");
                          languages[1].Words.Add("l'inverno");
                          languages[1].Words.Add("Macchina");
                          languages[1].Words.Add("Come stai");
                          languages[1].Words.Add("perché");
                          languages[1].Words.Add("buona notte");
                          languages[1].Words.Add("Grazie");
                          languages[1].Words.Add("mi chiamo..");
                          languages[1].Words.Add("abito a..");
                          languages[1].Words.Add("ragazzo");
                          languages[1].Words.Add("ragazza");
                          languages[1].Words.Add("matita");
                          languages[1].Words.Add("Uomo");
                          languages[1].Words.Add("donna");
                          languages[1].Words.Add("amico");
                          languages[1].Words.Add("Buona Fortuna");
                          languages[1].Words.Add("Caldo");
                          languages[1].Words.Add("Freddo");
                          languages[1].Words.Add("Quanti hanni hai?");
                          languages[1].Words.Add("come ti chiami?");
                          languages[1].Words.Add("Aereo");

                          languages[2].Words.Add("Bonjour");
                          languages[2].Words.Add("au revoir");
                          languages[2].Words.Add("chat");
                          languages[2].Words.Add("Bonjour a tous");
                          languages[2].Words.Add("Chien");
                          languages[2].Words.Add("été");
                          languages[2].Words.Add("Hiver");
                          languages[2].Words.Add("voiture");
                          languages[2].Words.Add("Comment vas-tu?");
                          languages[2].Words.Add("parce que");
                          languages[2].Words.Add("bonne nuit");
                          languages[2].Words.Add("Merci beaucoup");
                          languages[2].Words.Add("je m'appelle");
                          languages[2].Words.Add("J'habite a");
                          languages[2].Words.Add("Garcon");
                          languages[2].Words.Add("fille");
                          languages[2].Words.Add("Crayon");
                          languages[2].Words.Add("Homme");
                          languages[2].Words.Add("Femme");
                          languages[2].Words.Add("Ami");
                          languages[2].Words.Add("Bonne chance");
                          languages[2].Words.Add("Chaud");
                          languages[2].Words.Add("du froid");
                          languages[2].Words.Add("Quel age avez-vous?");
                          languages[2].Words.Add("Quel est votre nom?");
                          languages[2].Words.Add("Avion"); }      
     

这是我尝试运行以将列表链接到   单选按钮。

     

私人无效btn_play_Click(对象发送者,EventArgs e)               {

            if(rdo_english.Checked == true)
            {
                    language_picked = Convert.ToString(languages[0]);

            }
            if(rdo_italian.Checked == true)
            {
                    language_picked = Convert.ToString(languages[1]);
            }
            if(rdo_french.Checked == true)
            {
                    language_picked = Convert.ToString(languages[2]);
            }
            if(rdo_english2.Checked == true)
            {
                    language_picked = Convert.ToString(languages[0]);
            }
            if(rdo_italian2.Checked == true)
            {
                    language_picked = Convert.ToString(languages[1]);
            }
            if(rdo_french2.Checked == true)
            {
                    language_picked = Convert.ToString(languages[2]);
            }

我希望的是,当用户在检查了所需的语言后单击开始游戏时,相应的语言会自动与他/她的选择绑定。

0 个答案:

没有答案