最好给出一段代码

解决方案 »

  1.   

    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.Button myButton = null;
    private void button1_Click(object sender, System.EventArgs e)
    {
    myButton = new Button();
    myButton.Left = 100;
    myButton.Top = 100;
    myButton.Width = 200;
    myButton.Height = 34;
    myButton.Text = "New Button";
    myButton.Visible = true;
    this.Controls.Add( myButton );
    }
      

  2.   

    除了顶级容器如form外,其他控件都能加载:
    例如,如果一个panel中要加一个控件
    panel.add(control)
      

  3.   

    public MyClass CreateMyObject(string DllFileName)
    {
    string filepath = null;
    if (DllFileName.StartsWith("/"))
    {
    filepath = Application.StartupPath + DllFileName.Replace("/","\\");
    }
    else
    {
    filepath = DllFileName;
    } if (File.Exists(filepath))
    {
    if (this._assembly==null)
    {
    this._assembly = Assembly.LoadFile(filepath);
    }
    MyClass obj = (MyClass)this._assembly.CreateInstance(DllClassName);
    return obj;
    }
    else
    {
    throw new FileNotFoundException();
    }
    }
      

  4.   

    这是不是你想要的效果?
        Private Sub BtnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnAdd.Click
            Dim TextBox1 As New TextBox
            With TextBox1
                .Text = "动态加的TextBox"
                .Visible = True
                .Width = 100
                .Top = 20
                .Left = 50
            End With
            Me.Controls.Add(TextBox1)    End Sub