title: Assigning a value from a user input textbox to another form
body: <p>I'm new to C# and I'm trying to create a login that passes information to the other forms of the program. Below is my LoginForm.cs, I'm trying to get the userID that was inputted to the txtUserID.text and pass it on to another class. I've already tried creating a global variable but nothing happened.</p>
  <pre><code>public partial class frmLogin : Form
      {
  
          public String getUserID;
          public frmLogin()
          {
              InitializeComponent();
          }
  
          private void btnSubmit_Click(object sender, EventArgs e)
          {
  
              Login login = new Login();
              DbConn conn = new DbConn();
              Employee emp = new Employee();
  
              //assign the txtbox value to variables
              String userID = txtUserID.Text;
              String pass = txtPassword.Text;
              
              //check first the authetincation of the AD
              bool checkADAuthentication = login.isADauthenticated(userID, pass);
              if (checkADAuthentication == true)
              {
                  //get the name indicated on the AD
                  String name = emp.getADEmpName();
                  MessageBox.Show(&quot;Welcome &quot; + name, &quot;Login Successful&quot;, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  
                  //check if the connection to the SQL Database is establish
                  bool connDB = conn.isConnectionEstablish();
                  if(connDB == true)
                  {
                      
                      MessageBox.Show(&quot;Connection Successful&quot;, &quot;DB Connection&quot;, MessageBoxButtons.OK);
                      emp.getIdDetails(userID); //assign ID to function getIDDetails
                      getUserID = userID; //assign the User ID input from textbox to method getUser.
                      MessageBox.Show(getUserID, &quot;User signed in&quot;, MessageBoxButtons.OK);
                      StatusViewForm statView = new StatusViewForm();
                      this.Hide();
                      statView.Show();
                  }
                  else
                  {
                      MessageBox.Show(&quot;Connection not successful&quot;, &quot;Connection Failed&quot;, MessageBoxButtons.OK);
                  }
              }
              else
              {
                  MessageBox.Show(&quot;Login Failed&quot;, &quot;Login Unsuccessful&quot;, MessageBoxButtons.OK, MessageBoxIcon.Error);
              }
          }
      }
  </code></pre>
  <p>This is my StatusView Form where i'm trying to get the txtUserID.txt that was inputted to my LoginForm.cs</p>
  <pre><code>private void StatusViewForm_Load(object sender, EventArgs e)
          {
  
              frmLogin loginForm = new frmLogin();
              String loggedUser = loginForm.getUserID;
              MessageBox.Show(loggedUser, &quot;Who is logged in?&quot;, MessageBoxButtons.OK);
  
              QueryExecute taskEmp = new QueryExecute();
              DbConn dbConn = new DbConn();
              DataTable dt = new DataTable();
  
              //String userID = taskEmp.getEmployeeDetails(userID: loggedUser); ;
              String query = taskEmp.getTaskDetails(loggedUser);
              MessageBox.Show(query, &quot;Query&quot;, MessageBoxButtons.OK);
  
              SqlDataAdapter da = new SqlDataAdapter(query, dbConn.getDbConnection());
  
              dbConn.getDbConnection().Open();
              da.Fill(dt);
              dbConn.getDbConnection().Close();
  
              dgvTaskView.DataSource = dt;
  
          }
  </code></pre>
  <p>Problem is that everytime i run the program i can't get the value on the txtUserID.txt. You can see that i created a <code>MessageBox.show()</code> to check if the variable is being passed to the StatusViewForm.cs but it remains blank. Is there any way to do this in C#?</p>