Creating controls based on text in a database

Sam K

New member
Joined
Sep 6, 2008
Messages
3
Programming Experience
1-3
Sometimes my boss asks me questions that Im not really sure I know the answer to, or even if I understood the question right. Today was one of those days. Still, I wouldn't be a good development errand boy if I didn't try to dig up some useful information;

Essentially, what my boss wants to do is create a object(in this case a windows control) programatically, with the object created being determined by a text field in a database. For example, if the text field says "system.windows.forms.button", the code would create a button.
The key is that this needs to be flexible; if the field was changed to say "system.windows.forms.label" then the program needs to create a label object instead. This cant require restarting the program, or anything as such; if the database is updated the program needs to respond to the changes. Further, it cant be restricted to a list of pre-defined objects; if we (or more likely, our customers) decide new objects need to be created, the solution has to allow us to do this just by updating the database.

My boss was very clear that he (currently) doesn't care about the details (like defining the properties of the object created), he just wants to know if it can be done in .NET and if so how. Since Im not sure about this myself, I decided to take the question to the forums.

I realise Im probably not describing the requirements that well, I had this dropped in my lap just before the boss left to meet with customers, but Im doing the best I can to interpret his descriptions. At any rate, have anyone done anything like this, or know that it cant be done? Any information or thoughts about the subject would be welcome.
 
Do some research about Reflection, System.Reflection namespace. The Activator and Type classes are also very useful in this context.
 
Back
Top