这次合作,我们在讨论的时候发现,好多零碎的知识当时重构的时候查过,但是这次再用,还是记不住,也没有做总结,所以还得去查,所以这次就总结一些我在重构的时候遇到的一些小问题,和对应的解决方法,亦或是通过这个问题了解到的小知识。
private void frmAddUser_Load(object sender, EventArgs e) { cboUserLevel.Items.Add("操作员"); cboUserLevel.Items.Add("管理员"); txtUserName.Focus(); txtUserID.Text = "请输入8位以内用户名"; txtUserID.Font = new Font(txtUserID.Font.Name, 9); txtUserID.ForeColor = Color.Gray; txtUserPWD1.Text = "请输入16位以内密码"; txtUserPWD1.Font = new Font(txtUserID.Font.Name, 9); txtUserPWD1.ForeColor = Color.Gray; txtUserPWD1.PasswordChar = Convert.ToChar(0); }
private void txtUserID_Enter(object sender, EventArgs e) { txtUserID.Text = ""; txtUserID.ForeColor = System.Drawing.Color.Black; txtUserID.Font = new Font(txtUserID.Font.Name, 12); } private void txtUserPWD1_Enter(object sender, EventArgs e) { txtUserPWD1.Text = ""; txtUserPWD1.ForeColor = System.Drawing.Color.Black; txtUserPWD1.Font = new Font(txtUserPWD1.Font.Name, 12); }
private void txtUserPWD1_Leave(object sender, EventArgs e) { if (txtUserPWD1.Text == "") { txtUserPWD1.ForeColor = System.Drawing.Color.Gray; txtUserPWD1.Text = "请输入16位以内密码"; txtUserPWD1.Font = new Font(txtUserPWD1.Font.Name, 9); txtUserPWD1.PasswordChar = Convert.ToChar(0); } } private void txtUserID_Leave(object sender, EventArgs e) { if (txtUserID.Text == "") { txtUserID.ForeColor = System.Drawing.Color.Gray; txtUserID.Text = "请输入12位以内用户名"; txtUserID.Font = new Font(txtUserID.Font.Name, 9); } }