【发布时间】:2015-04-06 04:27:37
【问题描述】:
我有 2 种不同的表格,其中一种我生成客户列表,另一种我需要检索添加到列表中的信息。如何将列表传递给我的第二个表单?
这是第一个表格
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)
{
}
}
}
【问题讨论】:
-
使用这个你可以将值从一个表单传递到另一个表单codeproject.com/Questions/180489/…