试试这个:[DllImport("user32.dll", EntryPoint="DestroyWindow")]
public static extern int DestroyWindow (
int hwnd
);

解决方案 »

  1.   

    Remove后,buttonx是不是销毁了?我能再次调用创建buttonx的代码吗?
    this.buttonx = new System.Windows.Forms.Button();
    this.buttonx.Location = new System.Drawing.Point(150, 40);
    this.buttonx.Name = "buttonx";
    this.buttonx.TabIndex = 1;
    this.buttonx.Text = "buttonx";
    this.Controls.Add(this.buttonx);
      

  2.   

    REMOVE好像没有销毁,我测试过,要不用DESPOSE吧来干掉他
      

  3.   

    我能再次调用创建buttonx的代码吗?
    当然可以!
      

  4.   

    为什么一定要销毁呢?visible= false不就可以了?
      

  5.   

    我要释放资源
    close和dispose区别是什么?
      

  6.   

    为什么要释放资源
    .net提倡自动的垃圾收集
      

  7.   

    你让这个button不被任何对象引用,垃圾回收机制会帮你dispose它的