Winform Login Example Tutorial

winforms login page

LoginPage.cs

private void login_btn_Click(object sender, EventArgs e)
{
    result.Text = "Login check...";

    string id = user_id.Text;
    string pw = password.Text;
    
    //check id and pw
    if (id=="" || pw == "")
    {
    	MessageBox.Show("ID and Password could not be null");
        result.Text = "please check input value";
        return;
    }

    MessageBox.Show("Login Successful");
    this.Hide();
    frmMain fm = new frmMain();
    fm.Show();

}

winforms logout page

Logout_btn

frmMain.cs

private void Logout_btn_Click(object sender, EventArgs e)
{
    this.Hide();
    LoginPage fm = new LoginPage();
    fm.Show();
}