下面是用于重新加载上一页的按钮单击处理程序,但其次不能使用。
(First page)
private void button4_Click(object sender, EventArgs e)
{
this.DialogResult = System.Windows.Forms.DialogResult.OK;
selectdata sl = new selectdata();
sl.Show();
Visible = false;
}
(second Page)
private void button1_Click(object sender, EventArgs e)
List<CommonValue> CV = new List<CommonValue>();
foreach (DataGridViewRow item in dataGridView1.Rows)
{
if (Convert.ToBoolean(item.Cells[0].Value))
{
CV.Add(new CommonValue
{
Id = item.Cells[1].Value.ToString(),
Name = item.Cells[2].Value.ToString(),
description = item.Cells[3].Value.ToString(),
qty = item.Cells[4].Value.ToString(),
uom = item.Cells[5].Value.ToString(),
price = item.Cells[6].Value.ToString(),
});
}
}
this.DialogResult = System.Windows.Forms.DialogResult.OK;
trdata tr = new trdata();
tr.Values = CV;
tr.Show();
Visible = false;
}
这是Program.cs
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1 f1 = new Form1();
Form2 s1 = new Form2();
if (f1.ShowDialog() == DialogResult.OK)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
string result = s1.yourDesiredResult;
Application.Run(s1);
}
else
{
Application.Exit();
}
}
页面截图: