Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think the problem you are having is deciding how to communicate the "logged in" and "not logged in" status of the user between your login form and your Main form. </p> <p>One way of doing this would be to call a method or function that checks whether the credentials supplied by the user are valid and returns a value that represents whether login was successful or not. You could store this value in a form-level public <a href="http://msdn.microsoft.com/en-us/library/ms173118%28v=vs.80%29.aspx" rel="nofollow">Field</a> or <a href="http://msdn.microsoft.com/en-us/library/x9fsa0sw%28VS.80%29.aspx" rel="nofollow">Property</a>.</p> <p>You could then write code in the Main form to read this value from the Login form to determine the login status:</p> <p>Throughout the rest of your Main form, you could then set the text of your controls appropriately based on the login status:</p> <pre><code>if (userIsLoggedIn == true) { label1.Text = "Logged In" } else { label1.Text = "Not Logged In" } </code></pre> <p><strong>EDIT:</strong> In your Login form, you define a property (let's call it IsLoggedIn) which stores the login status. This can be a simple Boolean (true/false) value. You are opening the login form from your Main form - this means that you must have code that creates a new instance of the login form and displays it. Something like (C#):</p> <pre><code>LoginForm login = new LoginForm(); login.ShowDialog(); if (login.IsLoggedIn) { // update labels to Logged In } else { // update labels to not Logged In } </code></pre> <p>In the login form your code does the login checking and you store the result as follows:</p> <pre><code>// if successful, set logged in status to true this.IsLoggedIn = true; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload