views:

84

answers:

2

Hi,

When developing a WinForms app that will utilize a tab control to display different sets of data, is it best to add all my controls to the tabs directly, OR create user controls, add my controls to the UC and add the UC to each of the different tabs?

I was informed that the UC approach is best practice, and I understand some of the benefits, but I'm wondering if this is truly the way to go... any explanation either way is greatly appreciated!

+6  A: 

I have found that personally I do like the UserControl model, it helps get the code separate by each of the functions (tabs), and helps with UI design time.

You can do it either way, but I have had much better long-term success going the route of UserControl.

Mitchel Sellers
Agree. Though sometimes it complicates things when you want to share data between tabs or with elements outside of the tabs.
Nissan Fan
I also like this approach since it means that the UI can be loaded and unloaded dynamically "on-demand" in a fairly simple manner.
Fredrik Mörk
+2  A: 

In addition to the code separation, I think that adding the UC to a tab control ultimately makes it a lot more flexible. For example, if the UI changes over time and tabs are no longer necessary, it can easily be popped out and placed somewhere else. Or if the UC can be reused in a different context, it won't require a tab control to travel with it.

Ken