C# Query : When I login to my software I select the desired username using combobox. After I login, I want to see the username text in the main window on the toolstrip.
I tried get and set method but something is going wrong. Can you please help me out? Thanks in advance.
Form 1:
public partial class login : Form
{
public login()
{
InitializeComponent();
}
public string username
{
get{
return a.ToString();}
}
public string a;
private void button1_Click(object sender, EventArgs e)
{
a = comboBox1.Text;
Form main1 = new main();
main1.Show();
// rest is the code for login.
}
}
Form 2:
public partial class main : Form
{
public main()
{
InitializeComponent();
}
public string username
{
set { toolStripLabel1.Text = value; }
}
private void main_Load(object sender, EventArgs e)
{
Form home = new home();
home.MdiParent = this;
home.WindowState = FormWindowState.Maximized;
home.Show();
}
}
Here Home is form3 a childform which opens in Main form. at load event of Main form itself.