Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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.
 
Share this answer
 
v4
Comments
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.
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 ?) :

C#
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 ?!?!?
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900