2016-06-30 66 views
0

C#的WinForms,VS2015如何重命名一个winform不重新命名类

在设计师,如果我重新命名CustomerForm到frmCustomer,类也被改名为frmCustomer。我希望我的课程保持不变(CustomerForm)。由于

+0

你不能只是改变代码,'公共类frmCustomer'回到'公共类CustomerForm'?设计师在那里帮助改变代码引用。 – Bugs

+0

我使用了Resharper来做到这一点,但实例也被改回CustomerForm而不是frmCustomer – user1104916

+0

对不起,我明白你的意思了。设计器属性** Name **将与代码相同,因此'Public Class CustomerForm'将与设计器中的属性** Name **相同​​。不幸的是,我不认为它可以改变为不同的。 – Bugs

回答

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 

并不总是一个好方法,因为设计者可能揍随时这种变化。