winform中,怎么样传一个数组到另外一个winform中?

解决方案 »

  1.   

    在另个窗口的构造函数里加个数组参数.
    ex:
    Form1.cs中
    string[] a=....;
    Form2 form2 =new Form2(a);
      

  2.   

    在 Form2中
    public string []values = new string[10]; 
    在 Form1中
    Form2 form2 = new Form2();
    form2.values[0] ="xsjbxx.name";
    form2.values[1] = "xxjbxx.nj";
    form2.values[2] = "xxjbxx.RXNY";
    form2.values[3] = "xsjbxx.xbm";
    为什么在 Form2中values的值是空的呢?????
      

  3.   

    在Form1中定义一个临时的Form2的实例tempForm2,先对tempForm2的values数组赋值,操作完成以后将tempForm2赋值为Form2。
    步骤:
    1.//在 Form2中public string []values = new string[10]; 
    2.//将Form2当作参数传递到Form1中。你也可以在其他方法中这么做。public Form1(Form2 form2)
    {
        Form2 tempForm2 = new Form2();
        tempForm2.values = ......;
        form2 = tempForm2;
    }
    3.//在Form2或其他地方,调用values:String str = Form2.values[1];
    ......我是这么做的,好使。
    你可以试试:)