private void InitValidationRules() { if (userMode == UserMode.Add) { var userNameValidationRule = new UserNameValidationRule(); userNameValidationRule.ErrorText = "名称必须非空且还未被使用!"; dxValidationProvider1.SetValidationRule(textEditUserName, userNameValidationRule); dxValidationProvider1.SetIconAlignment(textEditUserName, ErrorIconAlignment.MiddleRight); var userTypeValidationRule = new UserTypeValidationRule(); userTypeValidationRule.ErrorText = "用户类型必须非空"; dxValidationProvider1.SetValidationRule(comboBoxEditUserType, userTypeValidationRule); dxValidationProvider1.SetIconAlignment(comboBoxEditUserType, ErrorIconAlignment.MiddleRight); } var userPasswordConfirmValidationRule = new UserPasswordConfirmValidationRule(); userPasswordConfirmValidationRule.ErrorText = "密码长度至少为6"; var userPasswordValidationRule = new UserPasswordValidationRule(); userPasswordValidationRule.ErrorText = "两次密码不匹配"; dxValidationProvider1.SetValidationRule(textEditPassword, userPasswordValidationRule); dxValidationProvider1.SetValidationRule(textEditPasswordConfirm, userPasswordConfirmValidationRule); dxValidationProvider1.SetIconAlignment(textEditPasswordConfirm, ErrorIconAlignment.MiddleRight); dxValidationProvider1.SetIconAlignment(textEditPassword, ErrorIconAlignment.MiddleRight); }