3

我将让用户Forms在此期间创建RunTime并将它们添加到项目中。我在开源的帮助下完成了表单的设计和 UI Form Designer

这是图像Form Designer图片

假设我有足够的 Form1.cs 和 Form1.cs[Designer] 文件WinForm。但是如何将其编译为 DLL 或 EXE 并将其添加到项目中呢?有任何想法吗?有什么线索吗?

谢谢!!

编辑

它创建此代码。

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private System.Windows.Forms.Button button1;

    private System.Windows.Forms.TextBox textBox1;

    private System.Windows.Forms.CheckBox checkBox1;


    private void InitializeComponent()
    {
        this.button1 = new System.Windows.Forms.Button();
        this.textBox1 = new System.Windows.Forms.TextBox();
        this.checkBox1 = new System.Windows.Forms.CheckBox();
        this.SuspendLayout();
        // 
        // button1
        // 
        this.button1.Location = new System.Drawing.Point(71, 49);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(75, 23);
        this.button1.TabIndex = 0;
        this.button1.Text = "button1";
        this.button1.UseCompatibleTextRendering = true;
        this.button1.UseVisualStyleBackColor = true;
        // 
        // textBox1
        // 
        this.textBox1.Location = new System.Drawing.Point(71, 94);
        this.textBox1.Name = "textBox1";
        this.textBox1.Size = new System.Drawing.Size(100, 20);
        this.textBox1.TabIndex = 1;
        // 
        // checkBox1
        // 
        this.checkBox1.Location = new System.Drawing.Point(38, 184);
        this.checkBox1.Name = "checkBox1";
        this.checkBox1.Size = new System.Drawing.Size(104, 24);
        this.checkBox1.TabIndex = 2;
        this.checkBox1.Text = "checkBox1";
        this.checkBox1.UseCompatibleTextRendering = true;
        this.checkBox1.UseVisualStyleBackColor = true;
        // 
        // form1
        // 
        this.ClientSize = new System.Drawing.Size(292, 273);
        this.Controls.Add(this.checkBox1);
        this.Controls.Add(this.textBox1);
        this.Controls.Add(this.button1);
        this.Name = "form1";
        this.ResumeLayout(false);
        this.PerformLayout();
    }


}

我将自己对其余代码进行一些额外的编码。但我不知道如何编译并将其添加到主 exe 中?

4

1 回答 1

1

线索是 System.CodeDom.Compiler 我认为 Form1.cs 将不包含任何代码(在构造函数中调用 InitializeComponents 除外)。因此,如果您通过简单的字符串操作将其与设计器代码合并,您的工作会更容易。

于 2013-07-31T18:41:51.020 回答