Click here to Skip to main content
15,900,258 members
Home / Discussions / C#
   

C#

 
AnswerRe: UserControls Pin
densher14-May-09 7:19
densher14-May-09 7:19 
NewsRe: UserControls Pin
Eddy Vluggen14-May-09 8:15
professionalEddy Vluggen14-May-09 8:15 
GeneralRe: UserControls Pin
densher14-May-09 8:35
densher14-May-09 8:35 
QuestionSend a struct to external DLL Pin
Ronenb14-May-09 5:47
Ronenb14-May-09 5:47 
AnswerRe: Send a struct to external DLL Pin
DaveyM6914-May-09 7:32
professionalDaveyM6914-May-09 7:32 
GeneralRe: Send a struct to external DLL Pin
Luc Pattyn14-May-09 8:17
sitebuilderLuc Pattyn14-May-09 8:17 
GeneralRe: Send a struct to external DLL Pin
DaveyM6914-May-09 8:32
professionalDaveyM6914-May-09 8:32 
QuestionCreating dynamic controls on a form Pin
fracalifa14-May-09 5:09
fracalifa14-May-09 5:09 
Hi all,

I want to create controls dynamicly on a form with the properties comming from a DataTable. (see code below)
The Table contains the infos like "name", "typ", "location", "size", ... of each control to create.

...
adapter.SelectCommand.CommandText = "SELECT * FROM controls WHERE controls_ID = 123";		
adapter.SelectCommand.Connection = conn;
adapter.SelectCommand.CommandTimeout = 60;
				
DS = new DataSet();
adapter.Fill(DS,"Ctrl");
System.Windows.Forms.Control[] X=null;

Table = DS.Tables["Ctrl"];
if(Table.Rows.Count>0)
{
   this.SuspendLayout();
   for(int i=0; i<Table.Rows.Count; i++)
   {
	DataRow row = Table.Rows[i];
	Type typ = Type.GetType(row["typ"].ToString());   // can be TextBox, Label, 
	typ X[i] = new typ();      // <-----here is the problem ------ how to assign/create the typ of control ? 
	X[i].Text = row["text"].ToString();
	X[i].Name = row["name"].ToString();
	this.Controls.Add(X[i]);
   }
   this.ResumeLayout();
}
...


how can I assign or create the right type of control. (see the marked row)
Is there an other way to do that ?

Thank you for your help
frank
AnswerRe: Creating dynamic controls on a form Pin
Luc Pattyn14-May-09 5:24
sitebuilderLuc Pattyn14-May-09 5:24 
GeneralRe: Creating dynamic controls on a form Pin
fracalifa14-May-09 7:47
fracalifa14-May-09 7:47 
GeneralRe: Creating dynamic controls on a form Pin
Luc Pattyn14-May-09 8:18
sitebuilderLuc Pattyn14-May-09 8:18 
Question[Message Deleted] Pin
Ankit Aneja14-May-09 5:07
Ankit Aneja14-May-09 5:07 
AnswerRe: datatype Pin
EliottA14-May-09 5:46
EliottA14-May-09 5:46 
GeneralRe: datatype Pin
Ankit Aneja14-May-09 5:48
Ankit Aneja14-May-09 5:48 
QuestionShape Control Pin
yogeshcprajapati@hotmail.com Yogesh14-May-09 3:47
yogeshcprajapati@hotmail.com Yogesh14-May-09 3:47 
AnswerRe: Shape Control Pin
Samer Aburabie14-May-09 3:50
Samer Aburabie14-May-09 3:50 
GeneralRe: Shape Control Pin
yogeshcprajapati@hotmail.com Yogesh14-May-09 6:40
yogeshcprajapati@hotmail.com Yogesh14-May-09 6:40 
QuestionRegular Expresion Pin
ONeil Tomlinson14-May-09 3:46
ONeil Tomlinson14-May-09 3:46 
AnswerRe: Regular Expresion Pin
OriginalGriff14-May-09 3:54
mveOriginalGriff14-May-09 3:54 
GeneralRe: Regular Expresion Pin
ONeil Tomlinson14-May-09 4:05
ONeil Tomlinson14-May-09 4:05 
GeneralRe: Regular Expresion Pin
OriginalGriff14-May-09 4:44
mveOriginalGriff14-May-09 4:44 
GeneralRe: Regular Expresion Pin
MidwestLimey14-May-09 4:47
professionalMidwestLimey14-May-09 4:47 
AnswerRe: Regular Expresion Pin
MidwestLimey14-May-09 4:47
professionalMidwestLimey14-May-09 4:47 
GeneralRe: Regular Expresion Pin
ONeil Tomlinson14-May-09 4:54
ONeil Tomlinson14-May-09 4:54 
QuestionProblem to save usercontrol as .bmp image Pin
Seraph_summer14-May-09 3:40
Seraph_summer14-May-09 3:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.