如何在不重命名类的情况下重命名winform

时间:2016-06-30 11:57:23

标签: winforms

C#winforms,VS2015

在设计器中,如果我将CustomerForm重命名为frmCustomer,则该类也将重命名为frmCustomer。我希望我的课程保持不变(CustomerForm)。感谢

1 个答案:

答案 0 :(得分:0)

您可以进入设计器代码并在那里更改名称:

    #region Windows Form Designer generated code

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        this.SuspendLayout();
        // 
        // CustomerForm
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(284, 261);
        this.Name = "frmCustomer";
        this.Text = "Form1";
        this.Load += new System.EventHandler(this.CustomerForm_Load);
        this.ResumeLayout(false);

    }

    #endregion

并非总是一种好的方法,因为设计师可能会随时破坏这种变化。