dynamically adding controls to a winform
Posted on 2010-08-20
I am trying to create a data entry application that has an element of user configuration.
An XML file should allow a user to add controls to a winform.
<?xml version="1.0" encoding="utf-8" ?>
<!--Defines controls on a form-->
<Control type="TextBox" name="txtAndy">
<Size width="100" height="20"></Size>
<Control> ...... etc etc etc
I can't find a way of creating the control using the "name" in the XML file.
If a variable ctlname holds the string "txtAndy" what command can I use to create the object called txtAndy?
this.txtbox= new System.Windows.Forms.TextBox();
is what I need to create but I can't work out how to use txtAndy instead of txtbox
ctlname = new System.Windows.Forms.TextBox();
will obviously fail
Hope someone can help