Click here to Skip to main content
13,045,790 members (44,424 online)
Rate this:
Please Sign up or sign in to vote.
See more:
If I design a TabPage with texts and boxes created with specific values & visibility, then during processing some values get altered and some boxes get hidden & unhidden, is it possible to have a button that resets all these changes and re-displays the TabPage as per the original design, or do I have to hard code within the button's code the opposite of all the changes I've made ? I hope that makes sense !!!
Posted 24-Jan-12 2:52am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You will need to write this code yourself. Some of the controls have Reset(), Clear(), etc. methods you can make use of to save you some time.

I would create a Reset() method and in this method set all control values to what you want them to be for defaults that way you can call this method many times throughout your code.

If you wanted the tab page back exactly as it was at design time I guess you could always just reassign your tabPage variable to a new instance of your tab page.
Gary Heath 24-Jan-12 9:24am
Thanks LanFanNinja, it's just something I was wondering about, I'm not definitely coding it yet, but wanted to know if there was an "easy" way ...
LanFanNinja 24-Jan-12 9:36am
You're welcome. It is always a good idea plan out what your are wanting to do before you start trying to do it.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I was just wondering ... when my (small & new) Project starts up, I have this code right near the start (This is a "Method", is that right ?) :

        public KALCForm1()
            //Ensure comboBox is empty
            //Fill comboBox with an entry for each League in the Database
            SqlConnection cs = new SqlConnection(@"Data Source=MEDESKTOP;AttachDbFilename=J:\Users\Gary\Documents\Visual Studio 2010\Projects\KALeagueCup\KALeagueCup\KADatabase.mdf;Initial Catalog=myKADB;Integrated Security=True");
            SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM LEAGUES", cs);
            DataTable dt = new DataTable();
            for (int i = 0; i < dt.Rows.Count; i++)

Could this code be kept elsewhere and "Called" from here and from anywhere else if I wanted to re-display the original form, or am I thinking too much like a Mainframe programmer again ?!?!?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 24 Jan 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100