请问怎么创建一个动态控件数组,在创建后如何使用些控件.

解决方案 »

  1.   

    搂主时要动态创建控件吧?其实把控件放在DataGrid或DataList中的模板列中更方便.
      

  2.   

    for(int i=0;i<100;i++)
    {
    this.label1 = new System.Windows.Forms.Label();
    this.label1.Click += new System.EventHandler(this.btnCancel_Click);
    this.label1.Text=i;
    }
    在根据this.label1.Text的值判断用的什么控件
      

  3.   

    Button[] btnArray = new Button[10];
    //赋值
    for(int i = 0; i < 10; ++i)
    {
        Button b = new Button();
        b.Name = "button" + i.ToString();
        b.Size = new Size(20, 10);
        b.Location = new Point(0, i * 10);
        ……
        btnArray[i] = b;
    }//使用
    for(int i = 0; i < 10; ++i)
    {
        Button b = btnArray[i];
    }