private void ChangeInfomationLabel() { switch (usernameChange.IsUsernameTaken(textBox1.Text)) { case 0: label2.Text = "Username is avaliable"; label2.ForeColor = System.Drawing.Color.Green; break; case 1: label2.Text = "Username is already taken"; label2.ForeColor = System.Drawing.Color.Red; break; case 2: label2.Text = "Username is too long"; label2.ForeColor = System.Drawing.Color.Red; break; case 3: label2.Text = "Username is too short"; label2.ForeColor = System.Drawing.Color.Red; break; case 4: label2.Text = "Username contains spaces"; label2.ForeColor = System.Drawing.Color.Red; break; default: label2.Visible = false; break; } label2.Visible = true; }
private void UsernameTextBox_TextChanged(object sender, EventArgs e) { switch (changeUsername.IsUsernameTaken(UsernameTextBox.Text)) { case 0: label4.Text = "Username is avaliable"; label4.ForeColor = System.Drawing.Color.Green; break; case 1: label4.Text = "Username is already taken"; label4.ForeColor = System.Drawing.Color.Red; break; case 2: label4.Text = "Username is too long"; label4.ForeColor = System.Drawing.Color.Red; break; case 3: label4.Text = "Username is too short"; label4.ForeColor = System.Drawing.Color.Red; break; case 4: label4.Text = "Username contains spaces"; label4.ForeColor = System.Drawing.Color.Red; break; default: label4.Visible = false; break; } label4.Visible = true; }