private void txt_UserName_KeyPress(object sender, KeyPressEventArgs e) { if (SpaceEntered == true) { e.Handled = true; } }