private void button3_Click(object sender, EventArgs e)
        {
            Button bt = new Button();
            bt.DialogResult = DialogResult.OK;
            bt.Visible = true;
            bt.Height = 52;
            bt.Width = 52;
            
        }
应该来说我点按钮,就可以多出一个出来,但事实上,根本就不行,大家帮忙看一下怎么回事.

解决方案 »

  1.   

    你都只是new了按钮,没有添加到显示的界面,当然出不来了。这样:
    private void button3_Click(object sender, EventArgs e) 
            { 
                Button bt = new Button(); 
                bt.DialogResult = DialogResult.OK; 
                bt.Visible = true; 
                bt.Height = 52; 
                bt.Width = 52; 
                this.Controls.Add(bt);
            } 
      

  2.   

    this.bt.Location = new System.Drawing.Point(3, 32);
      

  3.   

    this.bt.Location = new System.Drawing.Point(this.Width-bt.Width, 32);
      

  4.   

    bt.Dock = XXX.Right..
    具体忘了。你 = 的时候会有枚举提示的
      

  5.   

    bt.Dock = XXX.Bottom | XXX.Right .. 
      

  6.   

    还有最后一个问题,我发现这种方式用在MDI窗体上就没有效果了,
    打开代码如下
                    Ainventory ait = new Ainventory(sql);
                    ait.ShowInTaskbar = false;//不显示窗体
                    ait.ShowDialog();
    重载的代码如下
    public Ainventory(string sql2)
            {
                InitializeComponent();            
                dsql2 = sql2;
                //建立一个按钮返回确定 
                Button bt = new Button();
                bt.DialogResult = DialogResult.OK;
                bt.Visible = true;
                bt.Height = 50;
                bt.Width = 50;
                bt.Left = 900;
                bt.Top = 500;
                bt.Text = "确定";
                this.Controls.Add(bt);
            }
    结果没有发现出来有button, 不知道是不是因为Ainventorye 有其它控件,把它给遮住了,如果我想提到最长层该如何弄呢
      

  7.   

    this.bt.Location = new System.Drawing.Point(this.Width-bt.Width, this.Height-bt.Height);//绑定边缘
    this.btAnchor = AnchorStyles.Bottom | AnchorStyles.Right;
      

  8.   


    this.bt.Location = new System.Drawing.Point(this.Width-bt.Width, this.Height-bt.Height);//绑定边缘
    this.bt.btAnchor = AnchorStyles.Bottom | AnchorStyles.Right;刚才少打了一句
    这句才对的
      

  9.   

    private void button3_Click(object sender, EventArgs e) 
            { 
                Button bt = new Button(); 
                bt.DialogResult = DialogResult.OK; 
                bt.Visible = true; 
                bt.Height = 52; 
                bt.Width = 52; 
                this.Controls.Add(bt); 
            } 
    能出来了  其他属性自己定义。ok
      

  10.   

    csdn定律一:越简单的问题回复的越多
      

  11.   


    你的子窗体已经被其他控件遮盖住了。你找到这个控件,首先它必须是个容器,比如GroupBox1,
    this.groupBox1.Controls.Add(this.button1);
      

  12.   

    直接的拖一个控件设置到底部的   然后new出来的button就放到里面也行
      

  13.   

    一楼说正解
    private void button3_Click(object sender, EventArgs e) 
            { 
                Button bt = new Button(); 
                bt.DialogResult = DialogResult.OK; 
                bt.Visible = true; 
                bt.Height = 52; 
                bt.Width = 52; 
                this.Controls.Add(bt); 
            }