1 使用屬性傳值
(子表格)
私有ArrayList arlOut;
public ArrayList arrIn//使用pulibc
{
放
{
this .arrlOut = value;//這裡不能用arrlIn而要單獨宣告一個變數
}
得到
{
返回這個 .arrlOut ;
}
}
(主表單,由其向子表單傳值)
using System.Collections;//ArrayList引用空間
私有ArrayList arlOut;
私人無效btnShowForm4_Click(物件發送者,EventArgs e)
{
Form4 form4StudentInformation = new Form4();
form4StudentInformation.arrlIn = this.arrlOut ;
form4StudentInformation.Show();
}
2 使用方法傳值
(主表格)
using System.Collections;//ArrayList引用空間
私有ArrayList arlOut;
私人無效btnShowForm3_Click(物件發送者,EventArgs e)
{
Form3 formStudentInformation = new Form3();
formStudentInformation.setArray(arrlOut);
formStudentInformation.Show();
}
(子表格)
私有ArrayList arlOut;
public void setArray(ArrayList arrayin)//使用pulibc
{
arlOut = arrayin;
}
3構造函數傳值
(子表格)
私有ArrayList arlOut;
public StudentOneInformationForm(ArrayList arrIn)//建構子中加入了參數
{
初始化組件();
arrlOut = arrlIn;
}
(主表格)
私人無效showFormInformation_Click(物件發送者,EventArgs e)
{
StudentOneInformationForm StudentOne = new StudentOneInformationForm(this.arrlOut);//傳參數
學生One.Show();
}