Thread: putting the the Form1() into codedom

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    731

    putting the the Form1() into codedom

    It's hard to explain in the title but I have a form I created in Code DOM using

    Code:
    public class Form1 : Form
    {
    ...
    }
    Than I have the

    Code:
    public Form1()
    {
        InitializeComponent();
    }
    I also need. But I tried making that a method of the class of the form and it complained about having the same name as the class.


    This is my code dom main class:

    Code:
    myclass = new CodeTypeDeclaration();
    myclass.Name = "Form1 : Form";
    myclass.IsClass = true;
    myclass.Attributes = MemberAttributes.Public;
    mynamespace.Types.Add(myclass);
    And here is the method I am trying to add to that class:

    Code:
    CodeMemberMethod Form3 = new CodeMemberMethod();
    Form3.Name = "Form1";
    Form3.Attributes = MemberAttributes.Public;
    myclass.Members.Add(Form3);
    Did I do somthing wrong in the class or what?

  2. #2

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    Well, what I got out of this is:

    CodeConstructor should be used to do what I want but I get these 2 errors.

    Code:
    22 :: 23 :: Invalid token ':' in class, struct, or interface member declaration
    
    24 :: 23 :: Class, struct, or interface method must have a return type
    Ignore the numbers they are useless in the type of Code DOM I am using.

    So aperently I can't use a CodeConstructor?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Putting several hashes together. Better than md5/sha1?
    By idleman in forum C++ Programming
    Replies: 5
    Last Post: 04-03-2009, 12:42 PM
  2. Linux Putting my children to sleep with futex!?
    By Abs in forum Linux Programming
    Replies: 18
    Last Post: 02-12-2009, 06:43 PM
  3. Help with putting data into an array
    By Tek12x in forum C Programming
    Replies: 14
    Last Post: 01-20-2009, 08:11 PM
  4. Replies: 6
    Last Post: 06-30-2005, 08:03 AM
  5. Putting the function body with the prototype
    By homeyg in forum C++ Programming
    Replies: 3
    Last Post: 12-11-2004, 04:20 PM