Design question - What event to use for updating comboboxes on multitab tabcontrol

This is simply a design question. I'm seeking advice. I have a single windows form with a tabcontrol containing two tabpages. The tabpages have an assortment of controls including comboboxes. Design and performance wise, where is the best place to put the code that binds the comboboxes to their respective datasources?
freenameAsked:
Who is Participating?
 
Bob LearnedCommented:
It is difficult to say what is the "best practice", but the "preferred method" for me is to do that in the Form_Load, but sometimes there is a lot of overhead to initializing all the controls on a multi-page TabControl, so it can be better accomplished in the Selecting event handler.

Bob
0
 
Bob LearnedCommented:
I am big fan of a data access layer class that provides all interfaces to the database.  If you want to get fancy, you could get involved with application frameworks, like CSLA or NHibernate.  If you want to keep it simple, it could be a class with a couple of methods to get the data that you need, and to write changes back to the database.

Bob
0
 
GewgalaCommented:
Yeah, if it's simplicity that you're going for just put it in the codebehind.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
Bob LearnedCommented:
Well, we haven't even about application type, so we can't assume that there is going to be a web page with a code-behind.

Bob
0
 
GewgalaCommented:
That's true, lol, didn't even check.  I assumed.  You know what happens when we assume...
0
 
freenameAuthor Commented:
Thanks for the replies. This is a Windows Form, so there is now codebehind. I also use a DataAccessLayer class to do the the Database work and the form is just to display the collection of data to the user. Therefore, my question was, when I go to display some of this data in ComboBoxes, where is the best place to do it; form_load event, tabpage_layout or some other. I'm doing some in the load event, the stuff that needs to be displayed immediately and some in the layout event for the tabpage. I just want to know if there is a "Best Practice" for this.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.