有个功能是这样,界面A弹出界面B,在界面B选值后传回界面A,
界面A: CIS_MAIN
private void comboBox2_DropDown(object sender, EventArgs e)
        {
            sp = comboBox2.Text;
            商品模查 商品模查0 = new 商品模查();
            商品模查0.GetForm(this);
            商品模查0.Show();
        }界面B: 商品模查
public CIS_MAIN 商品模查0 = null;
        public void GetForm(CIS_MAIN theform)
        {
            商品模查0 = theform;
        }
 private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            商品模查0.comboBox2.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
            商品模查0.textBox5.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString();
            商品模查0.textBox6.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString();
            this.Close();
        }现在界面C:也要使用界面B的功能,但B的语句是写死的,有什么办法加个变量弄成通用的.

解决方案 »

  1.   

    B里public static void aa()
    {
    //方法
    }c里B.aa();
      

  2.   

    委托实现数据传递
    http://topic.csdn.net/u/20100106/20/e9697297-75f9-4450-aaa9-da0da416cf41.html?39668
      

  3.   

    我觉得界面之间的传值 直接可以使用属性。
    private static string *****;
    publlic static string *****{
        get{};
        set{};
    }或者直接用公有的静态变量
      

  4.   

    很多方法都可以實現,我這裡這個比較簡單,我在很多項目中也用了這個方法,目前並未發先什麽問題。FORM1.CS:
          FORM2 FR2 = new FORM2();
          FR2.Owner = this;
          FR2.ShowDialog();
    FORM2.CS:
         
            Form1 FR1;
            FR1= (DnNote_Form)this.Owner;
            FR1.方法(參數);       //你需要用到參數的方法.