-2

So I have this Login form with username textbox, password textbox, and a button like what typical Login form looks like for my c# Windows Form Application that I'm currently developing.

Once login is successful, the user will be directed to the second form, which is basically like a menu prompting a user to choose which form he/she wants to go to next, for instance, adding, updating, delete product info, and some sorts. And then, there's this Transaction form.

What I'm trying to do is to fill out one of the textbox in Transaction form with the value(username) that was filled in on the Login form.

How can I do that?

zdrasvutye
  • 21
  • 2
  • 8
  • At login time (in login form), store the value in a static variable somewhere in a class within your project! you will be able to retrieve it anywhere, it is good to use properties for storing/retrieving such values! – Khaksar Weqar Oct 24 '15 at 11:10
  • 1
    http://stackoverflow.com/questions/1559770/send-values-from-one-form-to-another-form – M.kazem Akhgary Oct 24 '15 at 11:11
  • maybe this could help you http://stackoverflow.com/questions/26083803/how-to-pass-form1-value-to-form3-in-c-sharp – jLaw Oct 24 '15 at 12:23

1 Answers1

0

To do this you can Overload the form constructor and pass the value from first form to second form by form constructor.

public frmSecondForm()
{
  InitializeComponent();
}



public frmSecondForm(string txtUserName,string txtPassword)
{
   InitializeComponent();

   userName=txtUserName;

   password=txtPassword;
}

then in the first form call the second form by overloaded constructor like this:

frmSecondForm f=new frmSecondForm(un,pa);
f.ShowDialog();
Manos Nikolaidis
  • 21,608
  • 12
  • 74
  • 82