Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 28th, 2007, 05:29 PM
Authorized User
Join Date: Aug 2004
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Baby_programmer Send a message via MSN to Baby_programmer Send a message via Yahoo to Baby_programmer
Default runtime instatiation of form control

Hello all,
i have loaded assemblies from the following XML file and
<assembly name="SUITContainers" version="" culture="neutral" publickeytoken="b09fdef67bf60879"/>
<codebehind type="Sample_Application.SampleApp, Sample Application" />
<suitform text="My First Suit App" width="400" height="200" backcolor="DarkGray">
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);

The form i get doesnt set the properties.. i just get a blank form...
Please help...

Baby Prgrammer
Baby Prgrammer
Old November 29th, 2007, 05:05 AM
samjudson's Avatar
Friend of Wrox
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts

There is no code in there to add the control to the form, e.g. this.Control.Add(control);

/- Sam Judson : Wrox Technical Editor -/

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get control in runtime. Somesh C# 2005 1 March 24th, 2007 02:23 PM
How to get control in runtime. Somesh .NET Framework 2.0 1 March 7th, 2007 03:42 PM
How to Move Multiple Control on a form at runtime? sivavenugopal VB How-To 1 January 22nd, 2007 01:49 PM
I want to create button control in runtime. wongsak VS.NET 2002/2003 3 October 20th, 2006 07:10 AM
Create Control, Runtime jimmyfrank Access VBA 1 January 29th, 2005 10:40 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.