runtime instatiation of form control
Hello all,
i have loaded assemblies from the following XML file and
<suit>
<assemblies>
<assembly name="SUITContainers" version="1.0.0.0" culture="neutral" publickeytoken="b09fdef67bf60879"/>
</assemblies>
<codebehind type="Sample_Application.SampleApp, Sample Application" />
<suitform text="My First Suit App" width="400" height="200" backcolor="DarkGray">
</suitform>
</suit>
and i need help in setting properties of control,
// Iterate through and create form controls
foreach (XmlNode controlNode in rootNode.ChildNodes) {
if (controlNode.Name != "assemblies" && controlNode.Name != "codebehind") {
string controlTypeName = controlNode.Name;
foreach (Assembly asm in loadedAssemblies) {
foreach (Type t in asm.GetTypes()) {
if (t.Name.ToLower() == controlTypeName) {
ISuitControl controlObj = ((ISuitControl)Activator.CreateInstance(t));
// Setting form Properties, like back color etc/..
SuitForm form = null;
ArrayList values = new ArrayList();
Type t = control.GetType();
PropertyInfo[] properties = t.GetProperties(BindingFlags.Public | BindingFlags.Instance);
//object[] attrib = t.GetCustomAttributes(false);
object[] Attribs;
string val;
//Get properties
foreach (PropertyInfo property in properties) {
//Get properties tagged with Custom Attributes
Attribs = property.GetCustomAttributes(true);
foreach (object OAttrib in Attribs) {
if (OAttrib.GetType().Equals(typeof(SuitProperty))) {
//val = node.OwnerDocument.CreateAttribute(property.Name.T oLower().ToString());
MethodInfo mInfo = property.GetGetMethod();
val = mInfo.Name.ToString();
string vals = mInfo.Invoke(control, null).ToString();
System.Drawing.ColorConverter colConvert = new ColorConverter();
((SuitForm)control).BackColor= (System.Drawing.Color)colConvert.ConvertFromString ("red");//vals);
break;
}
}
}
The form i get doesnt set the properties.. i just get a blank form...
Please help...
Baby Prgrammer
__________________
Baby Prgrammer
|