我在项目中创建了一个次要表单,可以从主表单获取数据,并且当点击按钮时应该将一些数据传递回主表单。
以下是代码:
Add.cs:
private void button1_Click(object sender, EventArgs e)
{
main ma = new main();
ma.optionType = "add";
ma.optionName = txtName.Text;
ma.optionURL = txtURL.Text;
ma.optionInterval = "12";
//What should I pass here?
this.Close();
}
main.cs:
private string opt;// create a property
public string optionType
{
get
{
return opt;
}
set
{
opt = value;
}
}
private string opt2;// create a property
public string optionName
{
get
{
return opt2;
}
set
{
opt2 = value;
}
}
private string opt3;// create a property
public string optionURL
{
get
{
return opt3;
}
set
{
opt3 = value;
}
}
private string opt4;// create a property
public string optionInterval
{
get
{
return opt4;
}
set
{
opt4 = value;
}
}
我的问题是我不知道在什么事件中尝试获取来自add.cs的数据,当button1(在add.cs中)被点击后。我应该用哪个事件检查数据是否已经到达?