New ContainerControl from Database

Hi,

I have many containerControls on my App (desktop), and I need instantiate with the names that I found from MySql Database. In my table, I have a pair of strings that contain a name of the container control, and a name for the component(variable). It's for a permission system. But when I try to create a new control with the name from database, I have a type mismatch error, because I'm trying to create a container control from a String... 

Something like this…

Dim myVariable as new myContainerControlVariable

… where myVariable and myContainerControlVariable are Strings, with the names from database.

Someone can help ?

Thank’s

a factory method that can take a string & return an instance is probably in order

Hi Norman… Thank’s for reply.

I looked at factory methods, but my containers are very different between them. So, I think that is more easy to use a simple “select case”, where I can compare strings from table and instantiate de containers… I like to have something more “automatic”, or more “automagic”, but…

Thank’s

Oh no you basically need one global method that can return “any container”

Something like

[code]CreateByName( name as string) as ContainerControl
select case name
case “foo”
return new FooContainer
case “bar”
return new BarContainer

[/code]
and so on

Theres no “NewInstanceByName” which is basically what you’d need - so you have to write one

[quote=158149:@Norman Palardy]Oh no you basically need one global method that can return “any container”

Something like

[code]CreateByName( name as string) as ContainerControl
select case name
case “foo”
return new FooContainer
case “bar”
return new BarContainer

[/code]
and so on

Theres no “NewInstanceByName” which is basically what you’d need - so you have to write one[/quote]

Haha!! You are the guy! It’s exactly I need.

Thank’s Norman.