Your question doesn't exactly spell out what you want to do. Are you saying you want to create controls as specified from a SQL query? If so, you would have to do something like this:
bool haveCtrl = true;
DataRow row = datatable.Rows[0];
switch (row["ControleType"].Value.ToLower())
{
case "combobox" :
{
ComboBox ctrl = new ComboBox();
ctrl.Name = row["CtrlID"].Value;
ctrl.Location = new Location(Convert.ToInt32(row["CtrlXPos"].Value), Convert.ToInt32(row["CtrlYPos"].Value));
ctrl.Width = Convert.ToInt(row["CtrlWidth"].Value);
ctrl.Height = Convert.ToInt(row["CtrlHeight"].Value);
}
break;
case "textbox" :
{
}
break;
default :
haveCtrl = false;
break;
}
this.Controls.Add(ctrl);
Are you really sure you want to do that? If you're adding controls based on the data you're going to be using, I would create an appropriate number of
UserControl
objects and just add the one that is appropriate for the data that's going to be manipulated.