Link to home
Start Free TrialLog in
Avatar of rajesh_khater
rajesh_khater

asked on

Copying a Form from another VB.NET project in 2005 version

Hi,
I have a VB.NET 2005 project where I want to add an existing form from another VB.NET 2005 project.
When I right click my project and add an Existing item, I select all 3 files for the form i.e. the .vb file , the designer.vb file and the .resx file.

After the form gets added, when I double-click it, the form does not open. It gives some error message.

2 questions:
1. What is right way to import a form into an existing project ?
2. Why does .NET 2005 generate a separate designer file for a form ? Earlier in 2003, everything was in the same .vb file.
Avatar of dctuck
dctuck
Flag of United Kingdom of Great Britain and Northern Ireland image

1. What is the error message you receive? Generally, the method you mentioned would work
2. I think Microsoft decided it would be less confusing for developers if the UI code was separate from the business logic...
Avatar of dstanley9
dstanley9

The reason for the separate "designer" file is because of the use pf partial classes.  Now, the "designer" code (the code that studio generates to turn the visual form into code) is in a separate file from the custom code, so you don't have the "Designer Generated Code - Do not Modify" region (or something like that).  
Avatar of rajesh_khater

ASKER

But if I want to see the generated UI code from my project, is there a way I can add it to  my project ?
Can I safely modify the generated code ?
ASKER CERTIFIED SOLUTION
Avatar of dctuck
dctuck
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
While copying a form, is it also necessary to manually select the designer file also, or will Visual Studio automatically detect it and copy it too ?
If you just import the main file (e.g. Form1.vb), Visual Studio will automatically detect the Designer and resources files associated with it and also import those.