Question

In currently developing a project where I'm going to use a lot of combobox, in order to avoid repeating a lot of code I'm planning on building a user control containing a ComboBox that retrieve the data I need from my tables.

What is the best approach for this since I'm going to use a lot of different ComboBox with different tables ? Differents user controls for differents table or just 1 user control where I pass the table I need ?

Example:

Combo1
  Spring/Summer 2015/2016  
  Spring/Summer 2016/2017  
  Fall/Winter 2015/2016  
  Fall/Winter 2016/2017  

Combo2
  Collection 1  
  Collection 2  
  Collection 3  
  Collection 4  
  Collection 5  

These 2 combo will be repeated a lot of times in the project. My question is : should I create 2 user control (combo1UserControl,combo2UserControl) or just some comboUserControl with some parameteres like the name of the tables ?

Was it helpful?

Solution

Assuming you are using .NET, mentioning C#, I would look into data binding features first. Most UI toolkit Microsoft has made offer some form of data binding either to objects, object lists or ADO.NET datasets. Mixing your data retrieval with your UI controls is never a good idea, I would try and keep this external to your user interface.

Licensed under: CC-BY-SA with attribution
scroll top