使用C#中DropDownList中的选定项

时间:2017-01-20 10:49:28

标签: c# combobox

目前我正在为我们制作的小游戏编写编辑器,您将能够向API添加问题。

我想使用组合框来选择一种问题(文字,文字+图片等) 我似乎无法让组合框与所选项目一起使用。 如何过滤选定项目?

(文本框是硬编码的,请原谅我)

你可以在这里找到代码。

private void TypeSelectbox_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (TypeSelectbox.SelectedItem.ToString() == "Tekst")
        {

            #region Vraag Textbox and Label

            TextBox VraagTB = new TextBox();
            VraagTB.Width = 400;
            VraagTB.Location = new Point(370, 90);
            this.Controls.Add(VraagTB);

            Label VraagLb = new Label();
            VraagLb.Width = 500;
            VraagLb.BackColor = Color.Transparent;
            VraagLb.Location = new Point(370, 70);
            VraagLb.Text = "Wat wordt de vraag die U wilt toevoegen?";
            this.Controls.Add(VraagLb);

            #endregion

            #region Antwoord TextBoxes (A t/m D)

            TextBox Antwoord_A = new TextBox();
            Antwoord_A.Width = 150;
            Antwoord_A.Location = new Point(370, 200);
            this.Controls.Add(Antwoord_A);

            TextBox Antwoord_B = new TextBox();
            Antwoord_B.Width = 150;
            Antwoord_B.Location = new Point(600, 200);
            this.Controls.Add(Antwoord_B);

            TextBox Antwoord_C = new TextBox();
            Antwoord_C.Width = 150;
            Antwoord_C.Location = new Point(600, 280);
            this.Controls.Add(Antwoord_C);

            TextBox Antwoord_D = new TextBox();
            Antwoord_D.Width = 150;
            Antwoord_D.Location = new Point(370, 280);
            this.Controls.Add(Antwoord_D);

            #endregion

            #region Antwoord Labels (A t/m D)
            Label Antwoord_A_Lb = new Label();
            Antwoord_A_Lb.Width = 150;
            Antwoord_A_Lb.BackColor = Color.Transparent;
            Antwoord_A_Lb.Location = new Point(370, 180);
            Antwoord_A_Lb.Text = "Het antwoord voor optie A";
            this.Controls.Add(Antwoord_A_Lb);

            Label Antwoord_B_Lb = new Label();
            Antwoord_B_Lb.Width = 150;
            Antwoord_B_Lb.BackColor = Color.Transparent;
            Antwoord_B_Lb.Location = new Point(600, 180);
            Antwoord_B_Lb.Text = "Het antwoord voor optie B";
            this.Controls.Add(Antwoord_B_Lb);

            Label Antwoord_C_Lb = new Label();
            Antwoord_C_Lb.Width = 150;
            Antwoord_C_Lb.BackColor = Color.Transparent;
            Antwoord_C_Lb.Location = new Point(370, 260);
            Antwoord_C_Lb.Text = "Het antwoord voor optie C";
            this.Controls.Add(Antwoord_C_Lb);

            Label Antwoord_D_Lb = new Label();
            Antwoord_D_Lb.Width = 150;
            Antwoord_D_Lb.BackColor = Color.Transparent;
            Antwoord_D_Lb.Location = new Point(600, 260);
            Antwoord_D_Lb.Text = "Het antwoord voor optie D";
            this.Controls.Add(Antwoord_D_Lb);
            #endregion

        }

0 个答案:

没有答案