Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 188239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:58:17+00:00 2026-05-11T15:58:17+00:00

I’m working on an older .NET code base that has all the designer code

  • 0

I’m working on an older .NET code base that has all the designer code stuffed into the same code file as my code (pre – partial classes).

Is there a mechanism to tell Visual Studio 2008 to go back and refactor designer code into a X.designer.cs partial class file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:58:18+00:00Added an answer on May 11, 2026 at 3:58 pm

    What I just did was completely manually:

    1. Create yourform.Designer.cs
    2. Add it to Visual Studio (right click, add existing item)
    3. Add the partial keyword to your existing class.
    4. Add the namespace exactly like in the original cs to the yourform.designer.cs
    5. Inside this namespace, add the class definition (don’t forget to include the partial keyword). Do not add inheritance and/or interfaces to this partial class in Designer.cs.
    6. After this is done, you’re ready to cut and paste the following:

    a) Remove the components object you might have in your original Winform. If the application was .NET 1.1 you will have something like this:

        /// <summary>     /// Required designer variable.     /// </summary>     private Container components = null; 

    b) Add a new components object in the Designer class:

        /// <summary>     /// Required designer variable.     /// </summary>     private System.ComponentModel.IContainer components = null; 

    c) Unless you had a specific dispose method, this is the standard. If you don’t have any form Inheritance, I think that base.Dispose can be safety removed:

        /// <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 );     } 

    d) Copy all the code inside the #region Windows Form Designer generated code to the new Designer.cs class.

    e) You should also copy all the member variables for all your objects (labels, texboxes, etc. that you use in the designer).

    That should be all about it. Save and compile.

    Remember that a partial class can be split among N number of files, but all must share the SAME namespace.

    Is it worthwhile? Well, in my case, I had a bunch of huge 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…


    UPDATE:

    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.

    You also have to close 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 165k
  • Answers 165k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There are a couple of variants of a rename command,… May 12, 2026 at 12:33 pm
  • Editorial Team
    Editorial Team added an answer There is currently no way to build CLS-compliant assemblies from… May 12, 2026 at 12:33 pm
  • Editorial Team
    Editorial Team added an answer You might want to look at Google Protocol Buffers or… May 12, 2026 at 12:33 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.