在Form2的ButtonClick事件里实例化Form3然后设置Form3的TextBox的值

解决方案 »

  1.   

    1.在Form2中添加一个全局对象 Public Fm As Form
    2.在Form1中显示Form2之前设置 Form2.Fm = Form3
    3.在Form2中就可以通过Fm设置Form3中的所有东西了
      

  2.   

    Form3.TxtBox3.Text=内容;加在Form2的按钮单击事件中
      

  3.   

    C#是面向对象语言,Form也是类,你的问题也就是类之间相互引用的问题,如果不会的话,请多看看面向对象程序设计。
      

  4.   

    在form1里
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace WindowsApplication11
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.TextBox textBox1;
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null; public Form1()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.button1 = new System.Windows.Forms.Button();
    this.textBox1 = new System.Windows.Forms.TextBox();
    this.SuspendLayout();
    // 
    // button1
    // 
    this.button1.Location = new System.Drawing.Point(124, 148);
    this.button1.Name = "button1";
    this.button1.Size = new System.Drawing.Size(48, 24);
    this.button1.TabIndex = 0;
    this.button1.Text = "button1";
    this.button1.Click += new System.EventHandler(this.button1_Click);
    // 
    // textBox1
    // 
    this.textBox1.Location = new System.Drawing.Point(100, 76);
    this.textBox1.Name = "textBox1";
    this.textBox1.Size = new System.Drawing.Size(104, 21);
    this.textBox1.TabIndex = 1;
    this.textBox1.Text = "textBox1";
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(292, 273);
    this.Controls.AddRange(new System.Windows.Forms.Control[] {
      this.textBox1,
      this.button1});
    this.Name = "Form1";
    this.Text = "Form1";
    this.ResumeLayout(false); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } private void button1_Click(object sender, System.EventArgs e)
    {
    Form2 f=new Form2(this);
    f.Show();
    }
    }
    }
    在form2里
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;namespace WindowsApplication11
    {
    /// <summary>
    /// Form2 的摘要说明。
    /// </summary>
    public class Form2 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.TextBox textBox1;
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.Form xform  ; /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null; public Form2(System.Windows.Forms.Form myform )
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent();
    xform=myform; //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if(components != null)
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.textBox1 = new System.Windows.Forms.TextBox();
    this.button1 = new System.Windows.Forms.Button();
    this.SuspendLayout();
    // 
    // textBox1
    // 
    this.textBox1.Location = new System.Drawing.Point(72, 72);
    this.textBox1.Name = "textBox1";
    this.textBox1.Size = new System.Drawing.Size(128, 21);
    this.textBox1.TabIndex = 0;
    this.textBox1.Text = "textBox1";
    // 
    // button1
    // 
    this.button1.Location = new System.Drawing.Point(140, 132);
    this.button1.Name = "button1";
    this.button1.Size = new System.Drawing.Size(40, 16);
    this.button1.TabIndex = 1;
    this.button1.Text = "button1";
    this.button1.Click += new System.EventHandler(this.button1_Click);
    // 
    // Form2
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(292, 273);
    this.Controls.AddRange(new System.Windows.Forms.Control[] {
      this.button1,
      this.textBox1});
    this.Name = "Form2";
    this.Text = "Form2";
    this.ResumeLayout(false); }
    #endregion private void button1_Click(object sender, System.EventArgs e)
    {
    this.Text=xform.Text; 
    foreach ( System.Windows.Forms.Control  f in xform.Controls )
    {
      MessageBox.Show(f.Name);
    if (f.Name.ToString()=="textBox1")
    {
      //f.Text="这是第二个窗体的值";
    f.Text = this.textBox1.Text;
    };
    }
    }
    }
    }
    试试吧
      

  5.   

    http://www.csdn.net/Develop/read_article.asp?id=26433