Buttion btn=new Button();
btn.Location=....;

解决方案 »

  1.   

    1、你的程序要能分析你的ini文件中的信息,比如:类名,显示名字,位置,挂接的事件等等
    2、使用反射来创建吧;
      

  2.   

    for (int i = 0; i < 5; i++)
                {
                    btn = new Button();
                    btn.Location = new System.Drawing.Point(34, 12 + i * 30);
                      btn.Name = "button" + i.ToString();
                    btn.Text = "button" + i.ToString();
                    this.Controls.Add(btn);
                    btn.Click += new EventHandler(btn_Click);
                }
                    
            void btn_Click(object sender, EventArgs e)
            {
                Button button = (Button)sender;
            }
      

  3.   

    for (int i = 0; i < 5; i++) 
                { 
                    btn = new Button(); 
                    btn.Location = new System.Drawing.Point(34, 12 + i * 30); 
                      btn.Name = "button" + i.ToString(); 
                    btn.Text = "button" + i.ToString(); 
                    this.Controls.Add(btn); 
                    btn.Click += new EventHandler(btn_Click); 
                } 
                    
            void btn_Click(object sender, EventArgs e) 
            { 
                Button button = (Button)sender; 
            }