public static string aa;访问的时候
窗体名.aa;

解决方案 »

  1.   

    public static string aa或者在有aa的窗体定义
    public String GetAA
    {
        Get
        {
             return aa;
        }
    }
      

  2.   

    声明前一个form
    然后用f.aa
      

  3.   

    方法1:
    在项目中添加一个类Class1
    内容如下:
    using System;namespace WindowsApplication2
    {
    /// <summary>
    /// Class1 的摘要说明。
    /// </summary>
    public class Class1
    {
    private static string str;
    public Class1()
    {
    //
    // TODO: 在此处添加构造函数逻辑
    //
    } public string Str
    {
    get
    {
    return str;
    }
    set
    {
    str=value;
    }
    }
    }
    }在form1中button1中加入以下内容:
    private void button1_Click(object sender, System.EventArgs e)
    {
    string aa=textBox1.Text.Trim();
             Class1 cls=new Class1();
    cls.Str=aa;
    Form2 frm=new Form2();
    frm.Show();
    }在form2中button1中加入以下内容:
    private void button1_Click(object sender, System.EventArgs e)
    {
    Class1 cls=new Class1();
    textBox1.Text=cls.Str;
    }
    这样即可完成两个窗体间的变量传递(这是比较好的一种方法)方法2:
    在form窗口中加入声明:
    public static string str;在form2中button1中加入以下内容:
    private void button1_Click(object sender, System.EventArgs e)
    {
    str=textBox1.Text.Trim();
    Form2 frm=new Form2();
    frm.Show();
    }在form2中button1中加入以下内容:
    private void button1_Click(object sender, System.EventArgs e)
    {
    textBox1.Text=Form1.str;
    }