【发布时间】:2011-10-17 23:16:36
【问题描述】:
我在我的项目中创建了一个辅助窗体,它可以从主窗体中获取数据,并且应该在单击按钮时将一些数据传递给主窗体。
这是代码:
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;
}
}
我的问题是,在单击 button1(在 add.cs 中)后,我不知道何时尝试获取来自 add.cs 的数据。我应该通过什么事件检查数据是否到达?
【问题讨论】:
-
我是你自己回答的,请随时发布答案,它可能对其他人有所帮助。