I have a tabcontrol with 3 tabs. Every tab has a great deal of textboxes which I use to refresh the properties of an object. To save my time, I bind the textboxes.Text to the properties of my object. The main problem happens 'cause I can make the binding just when the properly tab is selected.
The thing is there is no need to walk through the tabs sometimes, cause my Object can be deserialized, so I may want to perform the calculations whitout even having to fill all the textboxes. In other words, sometimes I won´t select all the tabs and the bind won´t happen.
My solution was, on the Load event of the main form, to select each tab through code at least one time and perform the bindings properly. This works well, but creates a pretty bad cosmetic effect with one tab jumping to the other every time I start-up the program.
And all this explanation was to made to the question: Is there any way to select (put the focus is a more proper definition for what I want to do) in each tab, perform the bindings whithout changing "physically" the selected tab ?
Hmmm I don´t get it.
I already have a function to do that and the code works, the problem is I have to jump from one tab to the other so that I can make the bindings. The cosmetic effect is pretty bad. Is there other option ?
You can add the bindings in run time but the value doesn't seem to get added until the control is painted on the screen, which means you'll be back where you started. A different option is bind the objects to a datatable and then bind that to a datagridview and/or your textboxes. This way you can use the values from the datatable regardless of what is currently showing on the screen
Thanks for your interest in my problems tinstaafl .
I still haven´t tried it yet (the option with database), but if I load the values on the textbox, shouldn´t the correct tab be visible? This would make my original visual problem persist, cause I would have to make all the jumps as I am already doing, right ?
Yes the value doesn't seem to get loaded until the control is drawn on the screen. By using an intermediary collection to hold the values, you can still access those values even though the controls haven't loaded them yet.
btw, you don't need a database to use a datatable It can be declared and accessed independently. If datatables increase your learning curve too much, you could also use a List(Of ) to store the objects directly, and access their values.
I am sorry I haven´t answered in a while, but I was working on other parts of the program I was feeling better to work on. Your suggestion seems pretty simple and it solves other problems I have, thank you! I have no idea why, but somehow I was stuck with the idea of working of solving the problem using properties and I couldn´t get a light.
And lol, I was meaning "datatable", not "database". Not being a native on a language where words are linked together causes some troubles sometimes.Thanks again.
Question Answered as of 10 Months Ago by