Cly*_*yde 35 .net visual-studio
我正在研究一个较旧的.NET代码库,它将所有设计器代码都填充到与我的代码相同的代码文件中(预部分类).
是否有一种机制告诉Visual Studio 2008返回并将设计器代码重构为X.designer.cs分部类文件?
Mar*_*ini 36
我刚刚完成的手动完全是:
a)删除原始Winform中可能包含的组件对象.如果应用程序是.NET 1.1,您将得到以下内容:
/// <summary>
/// Required designer variable.
/// </summary>
private Container components = null;
Run Code Online (Sandbox Code Playgroud)
b)在Designer类中添加一个新的组件对象:
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
Run Code Online (Sandbox Code Playgroud)
c)除非您有特定的处置方法,否则这是标准.如果你没有任何形式的继承,我认为base.Dispose可以安全删除:
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose( bool disposing )
{
if ( disposing && ( components != null ) )
{
components.Dispose();
}
base.Dispose( disposing );
}
Run Code Online (Sandbox Code Playgroud)
d)将#region Windows窗体设计器生成的代码中的所有代码 复制到新的Designer.cs类.
e)您还应该复制所有对象(您在设计器中使用的标签,texbox等)的所有成员变量.
这应该是关于它的全部.保存并编译.
值得吗?好吧,在我的情况下,我有一堆巨大的 winforms与大量的代码和控件.每次我从设计师切换到设计师时,VS2008都会爬行.这使代码视图更具响应性.我记得在有响应代码之前必须等待3-5秒.现在需要1 ...
执行步骤1到5并移动现有控件或添加新控件不会自动将任何内容移动到designer.cs类.新的东西进入了新的Designer类,但不幸的是旧的东西仍然存在.
您还必须关闭并重新打开文件(在添加/创建分部类之后),以便VS在Designer中正确绘制; 如果不这样做可能会导致绘制空表格.
| 归档时间: |
|
| 查看次数: |
9417 次 |
| 最近记录: |