Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# tabs
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 3:52am
Rate this: bad
good
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.
  Permalink  
v4
Comments
Gary Heath at 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 at 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
good
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()
        {
            InitializeComponent();
            
            //Ensure comboBox is empty
            KALCcomboBox1.Items.Clear();
 
            //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();
 
            da.Fill(dt);
 
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                KALCcomboBox1.Items.Add(dt.Rows[i]["LeagueName"]);
            }
        }
 
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 ?!?!?
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 390
1 Jochen Arndt 165
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,032
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,220


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 24 Jan 2012
Copyright © CodeProject, 1999-2014
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