locked
How to rename Form1.cs tab RRS feed

  • Question

  •  Hi,
    When tried to create a new project using VS C#2008 express edition, the default value of the form is From1.cs and Form1.cs [design]. Since I wanted to rename the form1.cs to MyProject.cs, I right clicked on the form1.cs in the solution explorer and tried to renamed it. I saw that it changed the name everywhere except on the tabs. It changes the name on the Solutions Explorer, but not on the designer view and code view tabs. I tried to close the tabs and reopened it. But it still did not work. I happen to observe that in the windows explorer, when I checked the file names under the Project name, I still see three files with Form1 name--Form1.cs, Form1.Designer.cs, and Form1.resx. Probably that is the reason the tab names are different from actual classes' names. I even tried to right clicked on visual c# 2008 icon and selected Run as Administrator. It still did not work. Could you tell me how to rename the tabs also so that they are inline with the classes they represent?
    Sunday, June 27, 2010 10:19 PM

Answers

  • That's pretty odd then.

    Maybe this sounds a little dumb, but I made a 'guide' how I did it.

    http://img94.imageshack.us/img94/5397/samplek.png

     

    Maybe there is something where it goes wrong. Otherwise you can manually change the file's name just by using the Windows Explorer and Notepad.

    • Marked as answer by Harry Zhu Thursday, July 1, 2010 8:27 AM
    Monday, June 28, 2010 7:45 PM
  • Are you sure that you're using C# 2008 Express (or 2010, it'll go the same there)? If so, I don't know the actual solution. You could rename the files extern, just using Notepad (Don't forget to edit those references to this form too). As an alternative you can report this 'bug' to Microsoft if no-one else knows an answer. And maybe you should try renaming the file in C# 2010 Express Edition. You could download that here.

    I'm sorry I were not able to give the (actual) answer, but I think this is a bug in your operating system(?). 

    • Marked as answer by Harry Zhu Thursday, July 1, 2010 8:27 AM
    Tuesday, June 29, 2010 7:12 AM

All replies

  • Hi howdy.amigo,

    In the Solution Explorer, right click and rename the item with Form icon rather than the .cs, it will then automatically rename all the 3 files.

    Hope this helps.


    Best regards,
    Ferry Meidianto | My Blog

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Sunday, June 27, 2010 10:34 PM
  • Hi Ferry Meidianto,

    Thank you for answering my question. I tried to do that, but it is changing the class names but not the Tab name. For some reason, it is not working for me. Please advise.

    Sunday, June 27, 2010 10:55 PM
  • Try closing those tabs first, then renaming the file, then double-clicking it again. It should open as a renamed tab now.

    Though when I try to rename it, everything goes fine, as well the tabs.

    Monday, June 28, 2010 12:10 PM
  • Hi Yoshi, I tried your suggestion. But I still get the same name on the tab, form1.cs. If you could suggest me how to cut and paste the screen, I can do that for your review. Please advice.

    Monday, June 28, 2010 7:31 PM
  • That's pretty odd then.

    Maybe this sounds a little dumb, but I made a 'guide' how I did it.

    http://img94.imageshack.us/img94/5397/samplek.png

     

    Maybe there is something where it goes wrong. Otherwise you can manually change the file's name just by using the Windows Explorer and Notepad.

    • Marked as answer by Harry Zhu Thursday, July 1, 2010 8:27 AM
    Monday, June 28, 2010 7:45 PM
  • Hi Yoshi,

    Probably because I am using Visual C# 2008 EXPRESS edition, I did not receive same dialog as yours when I tried to rename the form. It says RENAME as the dialog caption. And the following contents as listed with check boxes below the LOCATION:

     

    New Name:

    MyProject

    Location:

    WindowsFormsApplication1

    check box Preview reference changes

    check box Search in Comments

    check box Search in Strings

    Then it displayed all the locations where it is changing the form name. Then I clicked ok. At this point it did not change the tab name.

     

     

     

     

    Monday, June 28, 2010 10:54 PM
  • Are you sure that you're using C# 2008 Express (or 2010, it'll go the same there)? If so, I don't know the actual solution. You could rename the files extern, just using Notepad (Don't forget to edit those references to this form too). As an alternative you can report this 'bug' to Microsoft if no-one else knows an answer. And maybe you should try renaming the file in C# 2010 Express Edition. You could download that here.

    I'm sorry I were not able to give the (actual) answer, but I think this is a bug in your operating system(?). 

    • Marked as answer by Harry Zhu Thursday, July 1, 2010 8:27 AM
    Tuesday, June 29, 2010 7:12 AM
  • Thank you, Yoshi. I greatly appreciate it. I think I can live with it for now. :-) You have a nice day.
    Tuesday, June 29, 2010 5:20 PM
  • i got a solution for you

     

    rename the form, not by right click or F2, but in the File Name via the properties window.. worked for me and I was having the same problems

    Monday, March 28, 2011 6:14 PM
  • When you rename Form1.cs to lets say   OurForm remeber to add the ".cs".  To fix the current problem rename it back to Form1.cs and save then rename it toyour name with the .cs extension

    Monday, April 16, 2012 5:21 PM