public partial class Form1 : Form
{
public Label lblUsername, lblPassword, lblMessage;
public TextBox txtUsername, txtPassword;
public Button btnLogin;
public CheckBox chkShowPassword;
public Form1()
{
InitializeComponent();
lblUsername = new Label();
lblPassword = new Label();
lblMessage = new Label();
txtUsername = new TextBox();
txtPassword = new TextBox();
btnLogin = new Button();
chkShowPassword = new CheckBox();
lblUsername.Text = "Username: ";
lblPassword.Text = "Password: ";
lblMessage.Text = "LOGIN SUCCESSFULLY!";
txtPassword.PasswordChar = '*';
btnLogin.Text = "LOGIN";
chkShowPassword.Text = "Show Password";
this.Controls.Add(lblUsername);
this.Controls.Add(lblPassword);
this.Controls.Add(txtUsername);
this.Controls.Add(txtPassword);
this.Controls.Add(btnLogin);
this.Controls.Add(chkShowPassword);
lblUsername.Font = new Font("Segoe UI", 14, FontStyle.Regular);
lblPassword.Font = new Font("Segoe UI", 14, FontStyle.Regular);
lblMessage.Font = new Font("Segoe UI", 50, FontStyle.Regular);
txtUsername.Font = new Font("Segoe UI", 14, FontStyle.Regular);
txtPassword.Font = new Font("Segoe UI", 14, FontStyle.Regular);
btnLogin.Font = new Font("Segoe UI", 10, FontStyle.Regular);
chkShowPassword.Font = new Font("Segoe UI", 8, FontStyle.Regular);
txtUsername.Location = new Point(235, 115);
txtPassword.Location = new Point(235, 165);
lblUsername.Location = new Point(89, 115);
lblPassword.Location = new Point(89, 165);
chkShowPassword.Size = new Size(100, 175);
btnLogin.Location = new Point(250, 200);
btnLogin.Size = new Size(70, 40);
chkShowPassword.Location = new Point(250, 230);
chkShowPassword.CheckedChanged += new
EventHandler(chkShowPassword_CheckChanged);
btnLogin.Click += btnLogin_Click;
private void btnLogin_Click(object? sender, EventArgs e)
{
string username = "admin";
string password = "admin";
string form2Username = txtUsername.Text;
if (txtUsername.Text == username && txtPassword.Text == password)
{
MessageBox.Show(lblMessage.Text);
Form2 form2 = new Form2(form2Username);
form2.Show();
}
else
{
MessageBox.Show("Invalid Username or password.");
}
private void chkShowPassword_CheckChanged(object? sender, EventArgs e)
{
if (chkShowPassword.Checked)
{
txtPassword.PasswordChar = '\0';
}
else
{
txtPassword.PasswordChar = '*';
}
FORM 2 /////////
public Panel pnlCoverPhoto, pnlProfilePicture;
public Form2(string form2Username)
{
InitializeComponent();
pnlCoverPhoto = new Panel();
pnlCoverPhoto.Size = new Size(600, 150);
pnlCoverPhoto.BackColor = Color.FromArgb(66, 103, 178);
pnlCoverPhoto.Dock = DockStyle.Top;
pnlProfilePicture = new Panel();
pnlProfilePicture.Size = new Size(150, 150);
pnlProfilePicture.Location = new Point(10, 80);
pnlProfilePicture.BackColor = Color.FromArgb(0, 0, 0);
Label lblUsername = new Label();
lblUsername.Text = form2Username;
lblUsername.Location = new Point(pnlProfilePicture.Right + 20,
pnlCoverPhoto.Bottom - pnlProfilePicture.Height / 4);
lblUsername.Font = new Font("Segoe UI", 16, FontStyle.Regular);
lblUsername.ForeColor = Color.Black;
this.Controls.Add(lblUsername);
this.Controls.Add(pnlCoverPhoto);
this.Controls.Add(pnlProfilePicture);
}