none
Move a WinForm to another Project RRS feed

  • Question

  • Hi all, I'm trying to import a  2005 WinForm from a seperate project into a current project. I have not a clue where to attack this problem. A pointer in the right direction will most useful.

     

    regards

    johnb


    johnb
    Tuesday, October 19, 2010 11:08 AM

Answers

  • Well, it depends.  If the form uses strong typed datasets - driving a datagridview, for instance - then you'll have a lot of trouble.  If not, the easiest way I have found to do this is to copy the three files (*.vb, *.resx, *.designer.vb) in Windows Explorer to the folder in the new project, then do an Add Existing Item to the project in the Solution Explorer inside VS.

    Cheers


    Thanks,
    Corey Furman @ Facebook
    ______________________________________________________
    Please mark posts as answer or helpful when they are.
    Tuesday, October 19, 2010 11:26 AM
  • Yes I accept Corey Furman suggestion.

    Copying the physical files from old project to new project and then add these items to your new project is the best way. In this case you won't get any issue.


    Thanks and Regards, Bharath S.
    • Marked as answer by young-rascal Wednesday, November 3, 2010 4:51 PM
    Tuesday, October 19, 2010 11:31 AM
  • I want to stress that while my first reply directly answers your question, my second reply is likely the better solution.  If you ever need to change how this form operates and you have copied and pasted the files, you will have to make the same modification twice, whereas if you move the form to its own project, you will only need to make the modification once and then redistribute the new dll.  Code reuse is always better than copying and pasting.
    Thanks,
    Corey Furman @ Facebook
    ______________________________________________________
    Please mark posts as answer or helpful when they are.
    • Marked as answer by young-rascal Wednesday, November 3, 2010 4:51 PM
    Tuesday, October 19, 2010 11:45 AM
  • Because that we don't know if that form is an extra or the main project,

    You can start to try

    Solution Explorer 

    Right click on the project ->Add Existing Item -> browse to the form and get it.

    It will be copied in your project.

     


    Success
    Cor
    Tuesday, October 19, 2010 11:51 AM

All replies

  • Well, it depends.  If the form uses strong typed datasets - driving a datagridview, for instance - then you'll have a lot of trouble.  If not, the easiest way I have found to do this is to copy the three files (*.vb, *.resx, *.designer.vb) in Windows Explorer to the folder in the new project, then do an Add Existing Item to the project in the Solution Explorer inside VS.

    Cheers


    Thanks,
    Corey Furman @ Facebook
    ______________________________________________________
    Please mark posts as answer or helpful when they are.
    Tuesday, October 19, 2010 11:26 AM
  • Perhaps a better solution would be to move the form into its own project, then reference that new project from the pre-existing two others.


    Thanks,
    Corey Furman @ Facebook
    ______________________________________________________
    Please mark posts as answer or helpful when they are.
    Tuesday, October 19, 2010 11:27 AM
  • Yes I accept Corey Furman suggestion.

    Copying the physical files from old project to new project and then add these items to your new project is the best way. In this case you won't get any issue.


    Thanks and Regards, Bharath S.
    • Marked as answer by young-rascal Wednesday, November 3, 2010 4:51 PM
    Tuesday, October 19, 2010 11:31 AM
  • I want to stress that while my first reply directly answers your question, my second reply is likely the better solution.  If you ever need to change how this form operates and you have copied and pasted the files, you will have to make the same modification twice, whereas if you move the form to its own project, you will only need to make the modification once and then redistribute the new dll.  Code reuse is always better than copying and pasting.
    Thanks,
    Corey Furman @ Facebook
    ______________________________________________________
    Please mark posts as answer or helpful when they are.
    • Marked as answer by young-rascal Wednesday, November 3, 2010 4:51 PM
    Tuesday, October 19, 2010 11:45 AM
  • Because that we don't know if that form is an extra or the main project,

    You can start to try

    Solution Explorer 

    Right click on the project ->Add Existing Item -> browse to the form and get it.

    It will be copied in your project.

     


    Success
    Cor
    Tuesday, October 19, 2010 11:51 AM
  • Cory et al

    Thanks for the your reply and the others who took the time to comment. It's given me a focus which I did not have before.

    Moving a Form to its own project sound good but does it have a performance downside where a project has many references?

     

    Cheers Guys


    johnb
    Wednesday, October 20, 2010 3:38 PM
  • John - Are you really concerned that calling a dll is less efficient?  Yes, it probably is, but who cares?
    Thanks,
    Corey Furman @ Facebook
    ______________________________________________________
    Please mark posts as answer or helpful when they are.
    Wednesday, October 20, 2010 5:27 PM
  • Be aware that OOP is programming with reference. 

    Too what that reference point in memory is absolute irrelevant.

    So: no you are not loosing performance with many references all your VB Net (and every OOP program) is an endless part of references.

     


    Success
    Cor
    Wednesday, October 20, 2010 5:34 PM