public Form2(decimal x, decimal y, decimal z):this()
{
this.TextBox1.Text = Convert.ToString(x);
this.Label1.Text = Convert.ToString(y);
etc...
};
从主要形式
Form2 frm2 = new Form2(x,y,z);
frm2.Show();
0
创建一个新表单...
public class CalculationResultForm : Form
{
public CalculationResultForm(){}
public decimal Counter
{
set { labelCounter.Text = value.ToString(); }
}
public decimal Broad
{
set { labelBroad.Text = value.ToString(); }
}
public decimal Narrow
{
set { labelNarrow.Text = value.ToString(); }
}
private void OkButton_Click(object sender, EventArgs e)
{
// This will close the form (same as clicking ok on the message box)
DialogResult = DialogResult.OK;
}
}
5 回答
最简单的方法是添加一个新方法,让我们称之为ShowWithDetails:
一种方法是在第二种形式中创建一个新的构造函数 . 你可以使用第二种形式的那些值 .
从主要形式
创建一个新表单...
然后在现有的表单按钮单击处理程序...
有一篇描述how to do this without using ShowDialog()的博客文章 .
一种简单的方法是使用属性 . 您要将值传递给的表单只是另一个类 .
将这样的内容添加到第二种形式:
那么从第一种形式开始你就会做一些事情
或类似的规定 .