0

Say I have a project

And it has a form

enter image description here

I wanted to continue my development of Form1, but keep a copy of the current state of it. I suppose I could have tried making a copy of Form1, and renaming the copy as Form1_old so as to continue with the current one. But what I did was I made a renamed Form1 to Form1_old

So, I renamed Form1 to Form1_old it asked me if i want to rename all references, I said yes. I then got this

enter image description here

I then right clicked the Form1_old, clicked copy, then I right clicked the project in project explorer and clicked paste, and I got this

enter image description here

It doesn't look right because the Form1_old_Copy, has an item under it that just says Form1 and it won't rename.

And it's annoying because I want rename form1_old to form1, and my form1_old_Copy to Form1_old

So then I rename Form1_old to Form1 (it then appears above because of alphabetical order which is fine)

And then I get a similar problem with that one

enter image description here

My Form1.cs has something under it called Form1_old so that didn't get renamed

And my Form1_old_copy.cs has a thing under it called Form1

So the copy/paste and rename that I have done has made things messy.

What I want is anything under Form1_old_copy.cs to match that name.. And anything under Form1 to match that name

At this stage I don't mind deleting a form if I have to since they're both identical at this stage anyway. But it won't help because at the moment both forms are kind of corrupt in the sense that an item under them has a different name, and it doesn't look right to me, I don't want that.

barlop
  • 12,887
  • 8
  • 80
  • 109
  • Also to add if you rename `Form1` to `Form1_old` then copy it once you get `Form1` under `Form1_old - Copy` but if you copy `Form1_old` again and paste it you get `Form1_old - Copy (2)` then under that you get `Form1_old` which is weird. – P. Pat Mar 27 '17 at 02:31
  • related- see my answer here http://stackoverflow.com/questions/20420623/the-call-is-ambiguous-between-the-following-methods-identical-namespace-initial/20421004#comment73463844_20421004 VS may duplicate Initialize() method in main cs file and designer file, Both are partial classes, so if an error shows then can look for that and eg delete the one in the main file if it does that. – barlop Apr 03 '17 at 23:01
  • Thanks for sharing the link. It helped me a lot. – P. Pat Apr 04 '17 at 01:20

2 Answers2

2
  1. You could use some version control tool like github, svn,...
  2. But if you want to copy a form:
    • Copy and paste Form1, it will create a Form1-Copy form
    • Go to Form1-Copy.cs and change class name and constructor to Form1_Old
    • Go to Form1-Copy.designer.cs, change class name to Form1_Old
    • Change file name Form1-Copy.cs into Form1_Old.cs

Now you can continue your development with Form1

TriV
  • 5,118
  • 2
  • 10
  • 18
1

My Form1.cs has something under it called Form1_old so that didn't get renamed

I cannot speak to why it did not get renamed but to rename Form1_old, just

  1. Double click to open the code.
  2. Change the class name to whatever you want and the little light bulb will show up so choose Rename from it.

That will change and rename the item in solution explorer as well.

CodingYoshi
  • 25,467
  • 4
  • 62
  • 64