定义一个静态变量啊
From1中Public static String str = null;str =你想要的值 在From2中调用 From1.str 就行了 不过你问题没有说的明白 说的再明白点  怎么关联啊?

解决方案 »

  1.   

    我现在Form1中有个ListBox ,Form2中有个textBox 我想双击listBox一行时候显示Form2 并且textBox中的值为 listBox双击行的值
      

  2.   

    public static string str = null;str = listBox1.SelectedItem.ToString();在Form2中textBox1.Text = str;怎么不行呢
      

  3.   

    上面不是说了 是Form2.str  没懂?
      

  4.   

    加一个form2的带参数的构造函数
      

  5.   

    传值
    把FROM1的listbox值当参数传给FROM2
    在FROM2中定义个变量记录下
      

  6.   

    把comboBox 声明为public 变量
      

  7.   

    From1:
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace 窗体中的值传递
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.ListBox listBox1;
    /// <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 窗体设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.listBox1 = new System.Windows.Forms.ListBox();
    this.SuspendLayout();
    // 
    // listBox1
    // 
    this.listBox1.ItemHeight = 12;
    this.listBox1.Items.AddRange(new object[] {
      "我要分",
      "我要接分"});
    this.listBox1.Location = new System.Drawing.Point(88, 32);
    this.listBox1.Name = "listBox1";
    this.listBox1.Size = new System.Drawing.Size(120, 52);
    this.listBox1.TabIndex = 1;
    this.listBox1.DoubleClick += new System.EventHandler(this.listBox1_DoubleClick);
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(292, 266);
    this.Controls.Add(this.listBox1);
    this.Name = "Form1";
    this.Text = "Form1";
    this.ResumeLayout(false); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } private void listBox1_DoubleClick(object sender, System.EventArgs e)
    {
    string Value=listBox1.Text.ToString();
    Form2 form=new Form2(Value);
    form.Show();
    }
    }
    }
      

  8.   

    From2:
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;namespace 窗体中的值传递
    {
    /// <summary>
    /// Form2 的摘要说明。
    /// </summary>
    public class Form2 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.TextBox textBox1;
    private string _Value;
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null; public Form2(string Value)
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent();
    this._Value=Value; //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if(components != null)
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows 窗体设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.textBox1 = new System.Windows.Forms.TextBox();
    this.SuspendLayout();
    // 
    // textBox1
    // 
    this.textBox1.Location = new System.Drawing.Point(40, 40);
    this.textBox1.Name = "textBox1";
    this.textBox1.TabIndex = 0;
    this.textBox1.Text = "";
    // 
    // Form2
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(292, 266);
    this.Controls.Add(this.textBox1);
    this.Name = "Form2";
    this.Text = "Form2";
    this.Load += new System.EventHandler(this.Form2_Load);
    this.ResumeLayout(false); }
    #endregion private void Form2_Load(object sender, System.EventArgs e)
    {
    textBox1.Text=_Value;
    }
    }
    }
      

  9.   

    给From2加个参数
    From2  SHOW的时候把这个参数的值设为From1  ListBox里的选中的行的值
      

  10.   

    listbox控件好像有一个doubleclick事件委托的,在委托方法中写你要的操作就行了把?
    如在你双击listbox中的一行时,就会触发该事件,然后把那个textbox控件的visible=true,然后把双击的那行值赋给textbox的Text属性,事件数据e,貌似应该会有个e.rowindex什么的可以得到你当前双击的那行,然后listbox[e.rowindex],是这样?我也是个新手,多多包含