0

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 ?

  • The point of your question is reusing code... if you do 1 UC by table, it looks the same as using the combobox self. But maybe you should explain a bit what your goal is with an example. – Laurent S. Jan 28 '16 at 15:33
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.