本帖最后由 yjrdf 于 2009-11-13 11:21:14 编辑

解决方案 »

  1.   

    没看懂你说的啥意思,如要你是想要新new一个form且加控件的话,可以如下: private void button1_Click(object sender, EventArgs e)
            {
                //定义一个Form
                Form fm = new Form();
                //定义一个控件
                Button btn = new Button();
                btn.Text = "New Button";
                //把控件加到Form里
                fm.Controls.Add(btn);
                fm.Show();
            }
      

  2.   

    我想在新调用的frm中进行操作,添加的控件具有执行能力,就是说我怎么在新的form中添加的button中写代码执行操作呢呢?还有我们这样添加的button的位置怎么进行设置呀? 十分感谢!
      

  3.   

    添加完button以后给加个click事就有执行能力了
    button的位置可以用location来设置的
      

  4.   


     private void button1_Click(object sender, EventArgs e)
            {
                //定义一个Form
                Form fm = new Form();
                //定义一个控件
                Button btn = new Button();
                //回答:还有我们这样添加的button的位置怎么进行设置呀?---给Location赋值就行
                btn.Location = new Point(10, 10);
                //回答:就是说我怎么在新的form中添加的button中写代码执行操作呢呢?---给其加事件就行
                btn.Click += new EventHandler(btn_Click);
                btn.Text = "New Button";
                //把控件加到Form里
                fm.Controls.Add(btn);
                fm.Show();
            }
            //新加button的click 事件
            private void btn_Click(object sender, EventArgs e)
            {
                MessageBox.Show(((Button)sender).Text);
            }
      

  5.   

    已经回复你留言了,怕你收不到,再在这里说一下,你把textBox定义在方法外面就行
      

  6.   

    为什么不在设计的时候就把frm设置好...
    只是在程序主入口点调用的是Form1
    Application.Run(new Form1());
    这样不好...
    然后Button单击调用frm?
    不懂...
      

  7.   

     呵呵 因为我的两个界面都是要有人机交互式的,就是说在Form1,和新调用窗体fm中都有我要输入的东西进行选择,在选择完Form1后接着才进行fm中的操作。呵呵,谢谢指点!