我有兩種不同的形式,一種是我生成的客戶列表,另一種是我需要檢索添加到列表中的信息。我怎麼能通過我的第二種形式的名單?如何將一個表單中生成的列表傳遞給另一個表單(C#)?
這裏的第一個形式
List<Customers> new_customer = new List<Customers>();
private void newCustomer_Load(object sender, EventArgs e)
{
}
private void fNameTxtBox_TextChanged(object sender, EventArgs e)
{
}
private void lNameTxtBox_TextChanged(object sender, EventArgs e)
{
}
private void addressTxtBox_TextChanged(object sender, EventArgs e)
{
}
private void phoneNumTxtBox_TextChanged(object sender, EventArgs e)
{
}
private void emailTxtBox_TextChanged(object sender, EventArgs e)
{
}
private void IDTxtBox_TextChanged(object sender, EventArgs e)
{
}
private void addNewCustButton_Click(object sender, EventArgs e)
{
if (fNameTxtBox.Text != "" && lNameTxtBox.Text != "" && addressTxtBox.Text != "" && phoneNumTxtBox.Text != "" && emailTxtBox.Text != "" && IDTxtBox.Text != "")
{
new_customer.Add(new Customers { FName = fNameTxtBox.Text, LName = lNameTxtBox.Text, Address = addressTxtBox.Text, phoneNum = phoneNumTxtBox.Text, emailAdd = emailTxtBox.Text, ID = int.Parse(IDTxtBox.Text) });
MessageBox.Show("Thanks for Registering");
}
else
{
MessageBox.Show("Customer not added! Please fill out the entire form!");
}
}
}
}
而這裏的第二種形式:
namespace WindowsFormsApplication1
{
public partial class Current_Customers : Form
{
public Current_Customers()
{
InitializeComponent();
}
private void currCustComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
使用此可以將值從一個窗體傳遞給另一個窗體http://www.codeproject.com/Questions/180489/How-to-copy-all-the-items-between-listboxes-in-two – 2015-04-06 04:44:10