title: Windows Form Desktop application Log out
body: <p>On start of my Application <code>Login Form</code> comes up I have simply stored username and password and compared for validating user, if user is valid than <code>MDIparent Form</code> gets opened, Now I want to create <code>logout</code> for this Application. How I can do this?</p>
  
  <p>When I searched I Found That I can do this on FormClosing Event or FormClosed Event but what code should be written in that and for which form, only <code>Dispose();</code> is enough or something more? </p>
  
  <p>What if I want <code>Login Form</code> to get displayed back?</p>
  
  <p><strong>Showing MDI Form after Successful Login Like this</strong> </p>
  
  <pre><code>private void login_Click(object sender, EventArgs e)
          {   
              //if password true then send true           
              bool value = namePasswordEntry(getHashedUserName, txtUserName.Text, getHashedPassword, txtPassword.Text);
              if (value ==true)
              {                
                  MessageBox.Show("Thank you for activation!");
                  this.Hide();
                  Form2 pfrm = new Form2(txtUserName.Text);
                  pfrm.ShowDialog();    
              }
  
              else
              {
                  MessageBox.Show("Invalid LoginName or Password..");
              }       
          }
  </code></pre>