mjohnson3091
Freshman
I'm looking at creating a form layout dynamically from an XML document.
The parsing of the XML data i'm fine with and the creating of the controls I think I'm ok with, it's just the naming of them.
The code below is a cutdown example of what I'm using to draw the form.
I'm using C# and hope to deploy this onto mobile devices at some point.
In this example I'm using the name btn1, would I be better passing the names in the XML message? If so, how can I use the string field I get as a name (i.e.: If I pass the string "Button1" in the XML message and assign it to a string variable, strName, then will the new Button not take the name strName instead of its value)?
Hope that makes sense.
Thanks in advance.
The parsing of the XML data i'm fine with and the creating of the controls I think I'm ok with, it's just the naming of them.
The code below is a cutdown example of what I'm using to draw the form.
I'm using C# and hope to deploy this onto mobile devices at some point.
Code:
// Loop around the number of Data items and draw the form
for(intLoop=0;intLoop<dtData.Rows.Count;intLoop++)
{
switch(dtData.Rows[intLoop]["Type"])
{
case "Button":
{
Button btn1 = new Button();
btn1.Width=dtData.Rows[intLoop]["Width"];
btn1.Height=dtData.Rows[intLoop]["Height"];
// ..... etc. for the properties
this.Controls.Add(btn1);
btn1.Visible=true;
}
}
}
In this example I'm using the name btn1, would I be better passing the names in the XML message? If so, how can I use the string field I get as a name (i.e.: If I pass the string "Button1" in the XML message and assign it to a string variable, strName, then will the new Button not take the name strName instead of its value)?
Hope that makes sense.
Thanks in advance.