Persistence of values in Tabs

vidyajayakar

Member
Joined
Jul 25, 2005
Messages
5
Location
Boulder, CO
Programming Experience
Beginner
[Resolved] Persistence of values in Tabs

Hi,

I have a TabControl with 3 tab pages on it. I'm querying an Access database to populate control fields (like ComboBoxes and Listboxes) on the first tab. My problem is that if I make selections on the first tab, click on either of the other tabs and then come back to the first tab the fields go back to the default values (i.e., the first tab is loading again from scratch). I have just separated the form into tab pages to group similar fields together, but I need information from all 3 tabs before I can close the form. Is there some way I can enable persistence on these values till I close the form completely?

tia,
Vidya
 
Last edited:
you can use form level variables to store their selection and when the user goes back to a tab you can simply set the combobox's and listbox's selectedindex to the variables
 
Unless you're populating the control fields during the tabControl's SelectedIndexChanged event, the controls shouldn't be changing values when the selected tab is changed.
If you are using the SelectedIndexChanged event to populate the controls, I would suggest using the form's load event instead.
 
I am loading some of the controls during the form's load event, but most of the other controls are populated based on the selected items in the initial controls. I am storing the selected index values globally now, and I'm loading the values into the controls every time a user tabs. The user might tab frequently, which is making the app a little slow now.

Dont all the tabs come under the same form? Why do the controls get reset when I tab then?

Tia JuggaloBrotha & Paszt!
 
Put breakpoints on the methods that change the values in your controls so you can see when they get executed. It sounds like your code is flawed and you need to do certain things, i.e. set the control values, at a diiferent point in your code.
 
I too think there was a problem with the code :)
I now initialise all controls before using them (resetting the items and selecteditems for the control boxes) and now the values selected in the controls persist when I tab across pages. I didn't have to use any variables to store them.

Thanks for all the help!
 
Back
Top