我能够将数据从 child1 传输到 child2 表单没有问题并从 child1 表单打开 child2。但是我需要从主菜单栏打开 child2 并在文本框中传输数据。数据没有到达 child2然后我从父窗体打开 child2。这是代码:Child1(军官登录)
public string s;
public string Param
{
get { return s; }
set { s = value; }
}
public void LoginMethod()
{
try
{
OfficerBO user = new OfficerBO ();
user.OfficerID = txtOfficerId.Text;
user.Password = hs.PassHash(txtPassword.Text);
if (user.Login())
{
s = user.LastName;
MessageBox.Show("You Loged in Successfully\n\n" + user.FirstName +
" " + user.LastName );
OnLoginSuccess(null, null);
// this.Hide();
HolidayApp h = new HolidayApp();
// Data gets transfered into Child2 (HolidayApp) form
//and dialog opens no problem
h.ParamSet = Param;
h.ShowDialog();
}
else
{
txtOfficerId.Text = "";
txtPassword.Text = "";
MessageBox.Show("Invalid details");
}
}
catch (Exception ex)
{
MessageBox.Show("Error " + ex.Message);
}
}
Child2(假日应用程序):
public string ParamSet
{
get { return txtHolidaySurname.Text; }
set { txtHolidaySurname.Text = value; }
}
public void HolidayApp_Load(object sender, EventArgs e)
{
txtHolidaySurname.Text = ParamSet;
}
我需要帮助:成功登录后,我需要从主菜单栏中打开 HolidayApp (Child2),并在文本框中显示用户详细信息。请帮助或建议。
谢谢