我想使用将循环的变量制作组合框名称

时间:2018-11-01 04:43:59

标签: c# visual-studio-2008

int i=1;
int b=1;
private void button1_Click(object sender, EventArgs e)
{

    b++;

    if (i < b) {

        ComboBox nama = new ComboBox();

       /* comboBox2.Location = new System.Drawing.Point(39, locacom*angka);
        comboBox2.Name = "comboBox"+angka;
        comboBox2.Size = new System.Drawing.Size(156, 21);
        comboBox1.BackColor = System.Drawing.Color.Orange;
        comboBox1.ForeColor = System.Drawing.Color.Black;
        Controls.Add(comboBox2);
        label3.Text = i.ToString();
        i++;
        */
    }
    else
    {
        label2.Text = "Something went wrong";
    }

    label4.Text = angka.ToString();
    label5.Text = i.ToString();
    this.Refresh();
}

我已经尝试过一些 我无法提出新的东西 即:

ComboBox name + i.toString() = new ComboBox();
var names = name + i.toString();
ComboBox names = new ComboBox();

另一个问题:如果我可以使用相同的名称制作组合框,将会发生什么?

0 个答案:

没有答案