Is there a way to reset a usercontrol so that it is in it's orriginal state?  For instance... I have a usercontrol that has textfields, comboboxes, checkboxes, and an assortment of other items that get modified by the user.  Once the user clicks the 'submit' button I would like to reload that single control so that all of the fields that were modified are now in their orriginal state.  Oh... and this is for a WINDOWS APP.  thx
Who is Participating?
Sorry, no.

If you need that functionality, you will need to design it yourself.  Just add a method that sets the individual controls to a pre-defined state.  Or create a method that saves the default state, then another method to restore that state.
tolninjaAuthor Commented:
Thanks for the quick reply.  That's what I figured... I'm going to leave the question open for a little while longer just incase someone has a better solution.  thx
I think Bill-Hanson is 100% right about this one. If you want the controls to reset to an original state, you will have to store original values for all the controls and reset them manually in a method.

Here is a really simple example:

        // These constant variables should be declared globally in the class.
        private const Boolean DEFAULT_RECEIVE_NEWSLETTER = true;
        private const String DEFAULT_EMAIL_ADDRESS  = "";
        private const Int32 DEFAULT_AGE = 25;

        // Run this method to Reset the controls to the default values
        private void ResetControls()
            chkReceiveNewsletter.Checked = DEFAULT_RECEIVE_NEWSLETTER;            // CheckBox
            txtEmail.Text = DEFAULT_EMAIL_ADDRESS;                                                     // TextBox
            cmbAge.SelectedIndex = cmbAge.FindString(DEFAULT_AGE.ToString());       // ComboBox
Sorry I dont have code to help but if I could add one extra suggestion to the above and that is to instead of creating all of the constants hard coded, I would instead have Main call a function to store the default values this way changes in the IDE wont get changed by the constants, changes will propegate through.
tolninjaAuthor Commented:
Thanks.  I ended up writing a function to loop through every control and set it equal to "" if it was a textfield, label, etc.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.