【发布时间】:2015-12-30 15:54:10
【问题描述】:
我正在做一个创建 POS 系统的学校项目,我需要在不同的表单中通过相同的订单列表。问题是每次我返回主菜单时,列表都会刷新,尽管我仍然需要数据有没有办法防止这种情况发生?
public partial class Main : Form
{
List<string> order = new List<string>();
public Main()
{
InitializeComponent();
}
public Main(List<string> order)
{
InitializeComponent();
this.order = order;
}
这是主菜单的开始代码
这是将列表框中的项目添加到列表中的代码
private void confirmbtn_Click(object sender, EventArgs e)
{
order.AddRange(temp_order);
if (pendinglist.Items.Count != 0)
{
MessageBox.Show("Your Items have been added! yay!", "That Sushi", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("No items was selected.", "That Sushi", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
pendinglist.Items.Clear();
}
提前感谢您的帮助。如果代码还有其他问题,请告诉我。再次感谢您的帮助
【问题讨论】: