# Sunday, September 21, 2008

Any  forms/user controls added to a project after the VS2005  release are broken into partial classes. 

 

 

The Designer.cs part of the class contains the InitalizeComponent method, the dispose method, and the control declerations.  This makes the forms easier to work with.

 

When upgrading an old VS2003 project to 2005 it doesn’t automatically break up this code.  The old VS2003 forms and user controls can be updated to pull this code out so they’re easier to work with too. 

 

Step #1 Check out the form

 

Step # 2 Create a copy of the file and rename one of the files to end with Designer.cs

 

 

 

 

Step #3 Open the files in VS2005 outside of the project.  Just open the files directly. 

 

From the Form.CS file remove the InitializeComponent(), dispose, and control declarations

From the From.Designer.CS file remove everything BUT the InitializeComponent(), dispose, and control declerations

 

*Note that the designer file doesn’t need the using statements. 

 

Step #4 Set the class as a partial class

 

The designer file

 

 

 

From the cs file

 

 

Step #5 Reopen the project. Right click on the designer file and select Include In Project. 

 

 

 

 

 

Step #6 Do a Rebuild

 

Step #7 Makes sure the form designer opens

 

 

 

 

This does checkout the project file remember to turn the project file in when done. 

 

This refactoring makes the cs files smaller which makes them faster and easier to work with in VS

C# | Winforms
Sunday, September 21, 2008 5:46:43 PM (GMT Standard Time, UTC+00:00)
# Wednesday, September 03, 2008
 #
 


Wednesday, September 03, 2008 12:23:31 AM (GMT Standard Time, UTC+00:00)
# Sunday, August 24, 2008

I started this blog to have a little bit of a web presence.  I develop business logic, winforms, and reports at work so I thought it might be nice to get a little web development in.  I’m going to try and get one good technical post up a week they’ll probably have a .NET slant to them.  This seems like a reasonable goal, but who knows maybe after a while I’ll have to adjust that. 

Sunday, August 24, 2008 1:28:12 AM (GMT Standard Time, UTC+00:00)
# Wednesday, August 20, 2008
 #
 
Woot!

Wednesday, August 20, 2008 5:44:52 PM (GMT Standard Time, UTC+00:00)
Search
Navigation
On this page....
Archives
<September 2008>
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011
Aggregate Me!
Feed your aggregator (RSS 2.0)
More proof I'm a geek

Categories
Blogroll
Contact me
Send mail to the author(s) E-mail