V
VA_er
Guest
It is Mdi application, both FormLogin and FormDestination are child forms, I am trying to pass value from FormLogin to FormDestination, but I could not rebuild the solution, how to fix the error? Both screenshot and code are attached.
Thanks.
namespace Demo
{
public partial class FormLogin : Form
{
public FormLogin()
{
InitializeComponent();
}
private void FormLogin_Load(object sender, EventArgs e)
{
txtUsername.Text = Environment.UserName;
this.ActiveControl = txtPassword;
}
public string Username
{
get { return txtUsername.Text; }
}
public string Password
{
get { return txtPassword.Text; }
}
private void button1_Click(object sender, EventArgs e)
{
FormDestination fDestination = new FormDestination();
fDestination.Show();
this;
}
}
}
namespace Demo
{
public partial class FormDestination : Form
{
public FormDestination()
{
InitializeComponent();
}
private void DisplayUsernameAndPassword_Click(object sender, EventArgs e)
{
FormLogin fLogin = new FormLogin();
fLogin.ShowDialog(this); // make sure this instance of FormLogin is visible
MessageBox.Show("Username = " + fLogin.Username + "; Password = " + fLogin.Password);
}
}
}

Continue reading...
Thanks.
namespace Demo
{
public partial class FormLogin : Form
{
public FormLogin()
{
InitializeComponent();
}
private void FormLogin_Load(object sender, EventArgs e)
{
txtUsername.Text = Environment.UserName;
this.ActiveControl = txtPassword;
}
public string Username
{
get { return txtUsername.Text; }
}
public string Password
{
get { return txtPassword.Text; }
}
private void button1_Click(object sender, EventArgs e)
{
FormDestination fDestination = new FormDestination();
fDestination.Show();
this;
}
}
}
namespace Demo
{
public partial class FormDestination : Form
{
public FormDestination()
{
InitializeComponent();
}
private void DisplayUsernameAndPassword_Click(object sender, EventArgs e)
{
FormLogin fLogin = new FormLogin();
fLogin.ShowDialog(this); // make sure this instance of FormLogin is visible
MessageBox.Show("Username = " + fLogin.Username + "; Password = " + fLogin.Password);
}
}
}

Continue reading...