Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What I just did was completely manually:</p> <ol> <li>Create <em>yourform</em>.Designer.cs</li> <li>Add it to Visual Studio (right click, add existing item)</li> <li>Add the <em>partial</em> keyword to your existing class.</li> <li>Add the <em>namespace</em> <strong>exactly like in the original cs</strong> to the <em>yourform</em>.designer.cs</li> <li>Inside this namespace, add the <em>class</em> definition (don't forget to include the <em>partial</em> keyword). <strong>Do not</strong> add inheritance and/or interfaces to this partial class in Designer.cs.</li> <li>After this is done, you're ready to <em>cut</em> and <em>paste</em> the following: </li> </ol> <p>a) Remove the <em>components</em> object you might have in your original Winform. If the application was .NET 1.1 you will have something like this:</p> <pre><code> /// &lt;summary&gt; /// Required designer variable. /// &lt;/summary&gt; private Container components = null; </code></pre> <p>b) Add a new <em>components</em> object in the Designer class:</p> <pre><code> /// &lt;summary&gt; /// Required designer variable. /// &lt;/summary&gt; private System.ComponentModel.IContainer components = null; </code></pre> <p>c) Unless you had a <em>specific</em> dispose method, this is the standard. If you don't have any form Inheritance, I think that base.Dispose can be safety removed:</p> <pre><code> /// &lt;summary&gt; /// Clean up any resources being used. /// &lt;/summary&gt; /// &lt;param name="disposing"&gt;true if managed resources should be disposed; otherwise, false.&lt;/param&gt; protected override void Dispose( bool disposing ) { if ( disposing &amp;&amp; ( components != null ) ) { components.Dispose(); } base.Dispose( disposing ); } </code></pre> <p>d) Copy <strong>all</strong> the code inside the <strong>#region Windows Form Designer generated code</strong> to the new Designer.cs class. </p> <p>e) You should also copy <strong>all</strong> the member variables for all your objects (labels, texboxes, etc. that you use in the designer).</p> <p>That should be all about it. Save and compile. </p> <h2>Remember that a partial class can be split among N number of files, but all must share the SAME namespace.</h2> <p>Is it worthwhile? Well, in my case, I had a bunch of <strong>huge</strong> winforms with tons of code and controls. VS2008 crawled every time I switched from/to designer. This made the code view more responsive. I remember having to wait for 3-5 seconds before having a responsive code. Now it takes 1…</p> <hr> <h2>UPDATE:</h2> <p>Doing steps 1 to 5 and moving an existing or adding a new control won't automatically move anything to the designer.cs class. New stuff goes to the new Designer class, but old stuff remains where it was, unfortunately. </p> <p>You also have to <em>close</em> and reopen the file (after you have added/created the partial class) for VS to draw correctly in the Designer; failure to do may result in empty forms being drawn.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload