In order to build a form,you need to have form.cs and form.Designer.cs files.
Do not bother about resources(resx) file.
- Create an application that writes code into a TextWriter,the file should be written in such a way that you declare a control and add the control,set properties to the form and add it to the form.
For example:
textWriter.WriteLine("using System;");
textWriter.WriteLine("using System.Collections.Generic;");
textWriter.WriteLine("using System.ComponentModel;");
textWriter.WriteLine("using System.Data;");
textWriter.WriteLine("using System.Drawing;");
textWriter.WriteLine("using System.Linq;");
textWriter.WriteLine("using System.Text;");
textWriter.WriteLine("using System.Windows.Forms;");
textWriter.WriteLine("using System.IO;");
textWriter.WriteLine("namespace MyFramework.Gui.LoadItems");
textWriter.WriteLine("{");
textWriter.WriteLine(" public partial class Form1 : Form");
textWriter.WriteLine(" {");
textWriter.WriteLine(" public Form1()");
textWriter.WriteLine(" {");
textWriter.WriteLine(" InitializeComponent();");
textWriter.WriteLine(" }");
textWriter.WriteLine("}");
- A better option for creating a form builder is to read the schema of the database that we are using and according to the datatypes used in the database use corresponding controls in the form.For eg,if 'Name' is a column in table of type varchar, add a corresponding textbox with name txtName and a label lblName to the form and set properties for both controls.The various properties like top,Left etc can be set in the designer code for placing the controls properly.
- The same procedure can be used for building form.cs and inherit from Form class,make both classes partial.
- Now , if you add both designer and form.cs to a project they will work normally as a form built using toolbox and manual coding.
If you have any doubts please ask me.