ErrorProvider 구성 요소를 사용하려고합니다.ErrorProvider 구성 요소에 총구를 넣을 수 있습니까?
양식에 닫기 버튼이 있습니다. 물론 양식의 NE 모서리에 "X"가있는 것도 있습니다.
오류가 발생하면 닫기 단추 또는 닫기 상자 (또는 그 불일치가 무엇이든)가 응답하지 않거나 작동하지 않습니다.
양식에 오류가있을 때 사용자가 양식을 닫을 수 있도록하려면 어떻게해야합니까?
이 업데이트 : -
여기에 내가 "닫기"버튼의 OnClick() 핸들러 지금 노력하고있어 코드의 여전히 닫 거부 :
private void buttonCancel_Click(object sender, EventArgs e) {
formValidation.SetError(this, String.Empty);
Close();
}
다시 업데이트 : 그냥 우거지상, 나는 "DialogResult"속성을 "Close"버튼에서 "DialogResult"속성을 변경해 보았습니다.하지만 도움이되지 않았습니다. (짚에서 잡는 것을 기대하지 않았습니다.)
버튼의 "원인 확인"속성을 변경하지 않았습니다. 틀린 일 ...
는 다시 한번 업데이트 :
. . .
const int MINIMUM_PASSWORD_LENGTH = 5;
private string originalPassword {
get { return textCurrentPassword.Text; }
}
private string newCandidatePassword1 {
get { return textNewPassword.Text; }
}
private string newCandidatePassword2 {
get { return textNewPasswordRepeated.Text; }
}
public ChangePassword() {
InitializeComponent();
}
private void textCurrentPassword_Validating(object sender, CancelEventArgs e) {
string error = null;
if (originalPassword.Equals(String.Empty)) {
error = currentPasswordInvalid;
e.Cancel = true;
//textCurrentPassword.Focus(); probably unnecessary because of .SetError() below
};
// TODO: Replace 1==2 with call that compares password with the current user's confirmed password
if (1 == 2) {
error = currentPasswordDoesNotMatchCurrentUser;
e.Cancel = true;
}
formValidation.SetError((Control)sender, error);
if (null != error) {
;
}
}
private void textNewPassword_Validating(object sender, CancelEventArgs e) {
string error = null;
if (newCandidatePassword1.Length < 5) {
error = newPasswordInvalid;
e.Cancel = true;
}
formValidation.SetError((Control)sender, error);
if (null != error) {
;
}
}
private void textNewPasswordRepeated_Validating(object sender, CancelEventArgs e) {
string error = null;
// Long enough?
if (newCandidatePassword2.Length < MINIMUM_PASSWORD_LENGTH) {
error = newPasswordInvalid;
e.Cancel = true;
}
// New passwords match?
if (!newCandidatePassword2.Equals(newCandidatePassword1)) {
error = newPasswordsDoNotMatch;
e.Cancel = true;
}
// They match, but all three match (undesirable)
if (!originalPassword.Equals(newCandidatePassword1)) {
error = newPasswordSameAsOld;
e.Cancel = true;
}
// Unique across the user base?
// TODO: Replace 1==2 with call that verifies this password is unique
if (1 == 2) {
error = newPasswordNotUnique;
e.Cancel = true;
}
formValidation.SetError((Control)sender, error);
if (null != error) {
;
}
}
private void buttonCancel_Click(object sender, EventArgs e) {
foreach (Control ctrl in this.Controls) {
formValidation.SetError(ctrl, string.Empty);
}
Close();
}
[Windows 닫기 버튼 (X)을 사용할 때 Errorprovider에서 오류가 발생 함] (http://stackoverflow.com/questions/2481706/errorprovider-shows-error-on-using-windows-close-buttonx) –