private void button1_Click(object sender, EventArgs e) { TextBox usernameBox = this.Controls["usernameTextBox"] as TextBox; TextBox passwordBox = this.Controls["passwordTextBox"] as TextBox; TextBox nameBox = this.Controls["nameTextBox"] as TextBox; if (!usernameBox.Text.Equals("") && !passwordBox.Text.Equals("") && !nameBox.Text.Equals("")) { Boolean success = r.AddUser(new User(usernameBox.Text, passwordBox.Text, nameBox.Text)); if (success) { this.Close(); new Diginotes().Show(); } } }