How can I get my VS2003 Form files splitted in 2 Partial class flies like in VS2005 ?

T

TheSteph

In VS 2005 Form files are in 3 parts : From1.cs, Form1.Designer.cs and
Form1.resx.

In VS 2003 there is only one ".cs files".



How can I split my old VS2003 ".cs files" files in 2 files : From.cs and
Form.Designer.cs, and get thoses file "grouped" in the Solution explorer
under the main Form.cs file ?



Thanks for Help !



Steph.
 
M

Michael Nemtsev

Hello TheSteph,

In no way, VS 2003 doesnt support this

T> In VS 2005 Form files are in 3 parts : From1.cs, Form1.Designer.cs
T> and Form1.resx.
T>
T> In VS 2003 there is only one ".cs files".
T>
T> How can I split my old VS2003 ".cs files" files in 2 files : From.cs
T> and Form.Designer.cs, and get thoses file "grouped" in the Solution
T> explorer under the main Form.cs file ?
T>
T> Thanks for Help !
T>
T> Steph.
T>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 
G

Guest

Steph,
What you are referring to is "Partial Classes" which is strictly a .NET 2.0
Framework feature. Since Visual Studio 2003 cannot target the 2.0 framework,
you are out of luck.
Peter
 
T

TheSteph

In fact I have imported in VS2005 a project that I began with VS2003. But
after Importing my project in VS2005, the Form files have not been split by
the "Import/Conversion wizard", and I would like to know if It is possible
to do it in automated way ? (I have +/- 50 Forms to convert.)

I have tried manually, it works BUT the Solution Explorer show the
From.Designer.cs files at the same level than the Form.cs. (the
Form.Designer.cs files should be a child of the Form.cs node and I don't
know how to do it.)



Thanks !



Steph.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

TheSteph said:
In fact I have imported in VS2005 a project that I began with VS2003. But
after Importing my project in VS2005, the Form files have not been split
by
the "Import/Conversion wizard", and I would like to know if It is possible
to do it in automated way ? (I have +/- 50 Forms to convert.)


No idea really, what you could try is open one of the forms in the designer
and see what happen, IMO it will not work though.
 
N

Nicholas Paldino [.NET/C# MVP]

Steph,

There is no reason why it would split it apart. The code that you have
in .NET 1.1 is going to compile in .NET 2.0 (at least, for the most part).

The feature you are looking at is partial classes, which allows you to
separate a class definition into multiple files. The VS.NET people are
using this all over to separate the designer generated stuff from your
stuff.

Because it is not a requirement to use partial classes, the conversion
program doesn't touch it (since it isn't broke).

You might be able to get away with writing an app which will use CodeDOM
to parse your file, and then split it into two separate files, placing the
field declarations in one, and methods (except for InitializeComponent) in
another. In the end, it will not be easy though, since you can declare
fields anywhere in partial classes (and how do you know what you added, and
what was added previously by the designer).

Hope this helps.
 
T

TheSteph

OK. I Googled a bit and It seems that there is no tool to do that
automatically...



I found the solution to manually get it working right, I share to anyone
interested :



1.. Have a model of a simple "Form.Designer.cs" file and follow the model.
2.. Copy the Form.cs file and rename the copy 'Form.Designer.cs"
3.. The 2 main tricks are here :
- Do NOT work on this "INSIDE" the SOLUTION or the project. It will works
but the "Form.Design.cs" files will not go under the Form.cs node in the
Solution explorer. You can use VS2005, but open only the .cs files you are
working on !



- "Form.Designer.cs" have natively no "using" clause : so you have to insert
the full path in front of the component that are in the Form : example :



private StatusBar StbMain;



will be replaced by :



private System.Windows.Forms.StatusBar StbMain;



- Once you finished working on the files. Close them. Open the
solution. The Form.Designer.cs file will be under the right Form.cs node,
but the designer.cs files are "grayed" and with a "white" icon. Just
Right-cLick the designer.cs files and select "Add File to Project"; the file
will be no more grayed and with the right Icon.



That's it....







Well... 49 files remainning...





Thanks !



Steph.
 
T

TheSteph

OK. I Googled a bit and It seems that there is no tool to do that
automatically...



I found the solution to manually get it working right, I share to anyone
interested :



1.. Have a model of a simple "Form.Designer.cs" file and follow the model.
2.. Copy the Form.cs file and rename the copy 'Form.Designer.cs"
3.. The 2 main tricks are here :
- Do NOT work on this "INSIDE" the SOLUTION or the project. It will works
but the "Form.Design.cs" files will not go under the Form.cs node in the
Solution explorer. You can use VS2005, but open only the .cs files you are
working on !



- "Form.Designer.cs" have natively no "using" clause : so you have to insert
the full path in front of the component that are in the Form : example :



private StatusBar StbMain;



will be replaced by :



private System.Windows.Forms.StatusBar StbMain;



- Once you finished working on the files. Close them. Open the
solution. The Form.Designer.cs file will be under the right Form.cs node,
but the designer.cs files are "grayed" and with a "white" icon. Just
Right-cLick the designer.cs files and select "Add File to Project"; the file
will be no more grayed and with the right Icon.



That's it....







Well... 49 files remainning...





Thanks !



Steph.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top