Hi,
I am wondering if it is possible to do something. I have a function that reads an xml file and adds controls to a form based on the contents on the file. An xml node like this will create it:
<Button Top="300" Left="100">Automatic</Button>
I have a function that saves the controls back to the xml file if I have added any in an edit mode. It is working, but I am wondering if there is an easier way. Currently, I have code that looks like this to create an instance of each control:
switch (xmlchild.Name)
{
// Create a new control whose type is specified.
case "Button":
c = new Button();
break;
case "Label":
c = new Label();
break;
default:
c = null;
break;
}
But, when I want to use more types of controls, I will need to keep adding switch cases. Can I do something that will just take the text and add a control of that type? I would appreciate any feedback!
Thanks!