1 Attachment(s)
Copying a Form in Visual Basic 2010 Express
I wanted to copy a complex form I had created because there was another form that was nearly identical. Apparently this is very difficult in VB2010E. I tried a variety of techniques (copying files in windows explorer, editing with notepad to change classname, copying and pasting in the IDE window, etc.). I finally managed to get both forms to appear in my project, but I believe my vbproj file may have become corrupted because I cannot select one of the forms as my app's startup form (see attached). What is wrong here? Is my vbproj or my form corrupted? Is there a proper way to copy a form? When one imports a form, what files are needed (.vb? .designer.vb? .resx?)
Attachment 90335
Note how the form frmCategEnt is not available in the startup form drop-down.
I really don't want to have to create this form all over again. More importantly, I hope my vbproj file is not corrupted.
Re: Copying a Form in Visual Basic 2010 Express
You can copy a form from 1 project to another, rename it and then copy it back to the original project using Solution Explorer window (right click on the form, copy and right click on another project > paste). If your solution has only 1 project, you can add a new dummy project to it, copy the forms from the valid project to the dummy one, change the form name and class name (for class name, use the form's property window so that VS can properly update all the references). Once you're happy with the changes, copy the forms back to the valid project and delete the dummy one.
Re: Copying a Form in Visual Basic 2010 Express
Thanks for the clarification. That seems pretty absurd to me. I appreciate the help with this undocumented "feature" of VB.
Any suggestions about what to do with my possibly-corrupted VB Project above?
Re: Copying a Form in Visual Basic 2010 Express
You mean you understood that? I was going to suggest Project > Add Existing Item but I'm not sure I should now!
Whatever way you do it, you'll always have to resolve clashes of names, unreferenced variables, dependent files etc. before the addition can be considered suitable as a starting form.
Re: Copying a Form in Visual Basic 2010 Express
Quote:
Originally Posted by
dunfiddlin
You mean you understood that? I was going to suggest Project > Add Existing Item but I'm not sure I should now!
Unless I'm confused, he has suggested copying a form from my primary project to a different (possibly temporary) project in my VB Solution, renaming the item in question in that other project, and then copying/moving it back to the original project. This seems ridiculously convoluted to me, but it kind of makes sense that the IDE would take care to also copy any connected resources necessary for the form. I'm still not sure exactly what the .vb, .designer.vb, and resx files each represent. I tried adding existing item but for some reason it had problems -- don't recall specifically what they are now, but I think it was name conflicts and then when i try to open the form i get the "something happened" screen.
Quote:
Originally Posted by
dunfiddlin
Whatever way you do it, you'll always have to resolve clashes of names, unreferenced variables, dependent files etc. before the addition can be considered suitable as a starting form.
Will these be reported in the warnings/errors?
Re: Copying a Form in Visual Basic 2010 Express
Quote:
Originally Posted by
sneakyimp
Unless I'm confused, he has suggested copying a form from my primary project to a different (possibly temporary) project in my VB Solution, renaming the item in question in that other project, and then copying/moving it back to the original project. This seems ridiculously convoluted to me, but it kind of makes sense that the IDE would take care to also copy any connected resources necessary for the form. I'm still not sure exactly what the .vb, .designer.vb, and resx files each represent. I tried adding existing item but for some reason it had problems -- don't recall specifically what they are now, but I think it was name conflicts and then when i try to open the form i get the "something happened" screen.
Will these be reported in the warnings/errors?
Yes to the latter. And as kind of an answer to the former, the more complex the form the more challenges it represents. Ideally, you'd only add forms that have been stripped of code or are at least completely self contained.