借用Hashtable傳遞多筆使用者勾選資料至另一個Form
class Form1
{
private void button1_Click(object sender, System.EventArgs e)
{
Form2 f2 = new Form2();
f2.ShowDialog();
ArrayList alABC = f2.GetABC;
foreach(Hashtable ht in alABC)
{
MessageBox.Show(ht["A"].ToString() +"<=>" + ht["B"].ToString() +"<=>" + ht["C"].ToString());
}
}
}
class Form2
{
private ArrayList alABC;
public ArrayList GetABC
{
get
{
return alABC;
}
}
private void button1_Click(object sender, System.EventArgs e)
{
alABC = new ArrayList();
for(int i = 0 ; i < 3; i++)
{
Hashtable ht = new Hashtable();
ht.Add("A", this.textBox1.Text + i.ToString());
ht.Add("B", this.textBox2.Text + i.ToString());
ht.Add("C", this.textBox3.Text + i.ToString());
alABC.Add(ht);
}
this.Close();
}
}
Jenny:
陽光令人愉快,雨水令人振作,
風聲令人奮起,雪花令人興奮,
沒有所謂的壞天氣!!
只有不同的好天氣!!