Click here to Skip to main content
15,903,201 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
My from have TabControl
Tabcontrol have tabpage1 and tabpage2
UserControl1 add to Tabpage1, usercontrol2 add to tabpage2

I have a problem when I change select tabpage, how to reset UserControl's data

this my code
http://www.mediafire.com/?6x6iiz241126dol[^]
Posted

1 solution

One way is to make a public function on your UserControls that handles the rest logic for you:
C#
public void Reset()
{
     /// set the default values that you want for each property here
}

Then you can hook into the TabControl's Deselected event and call the reset function:
C#
private void tabControl1_Deselected ( object sender, TabControlEventArgs e )
{
    switch ( e.TabPageIndex )
    {
        case 0:
            this.userControl1.Reset ();
            break;
        case 1:
            this.userControl2.Reset ();
            break;
    }
}
 
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