Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7818059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:26:54+00:00 2026-06-02T06:26:54+00:00

I’m trying to use an ErrorProvider component. I have a Close button on the

  • 0

I’m trying to use an ErrorProvider component.

I have a Close button on the form, and of course it also has the “X” close thingy in the NE corner of the form.

Once an error has been “raised” though, clicking the Close button or the Close box (or whatever that doohicky is called) are unresponsive/nonfunctional.

What must I do to allow the user to dismiss the form when it has errors on it?

Update:

Here’s the code I’m trying now in the “Close” button’s OnClick() handler – it still refuses to close:

private void buttonCancel_Click(object sender, EventArgs e) {
  formValidation.SetError(this, String.Empty);
  Close();
}

Updated again: Just for grimaces, I tried changing the “DialogResult” property from Canceled to None on the “Close” button, but that did not help (didn’t expect it to – grasping at straws)

Neither did changing the button’s “Causes Validation” property from True to False…

Updated yet again:

Here’s all the pertinent that may or may not be fit to post:

        . . .
              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(); 
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:26:56+00:00Added an answer on June 2, 2026 at 6:26 am

    You can trying clearing SetError in your Close button handler:

    private void buttonCancel_Click(object sender, EventArgs e)
    {
        foreach (Control ctrl in this.Controls)
        {
            formValidation.SetError(ctrl, string.Empty);
        }
        Close();
    }
    

    Also double check that your buttonCancel is indeed hooked up to this handler. Put a breakpoint and make sure that you are at least getting into this function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.