Forum Discussion
nick1941
May 02, 2023Copper Contributor
Form1 Rename Problem in Visual Studio
If you create a Windows Forms project in Visual Studio 2022, it creates a Form1.cs file, a Form1.cs [Design] form, and a Form1.Designer.cs file. You can then drag items from the toolbox onto the form or select the form and using the form properties window to add event handlers like OnPaintForm1, and the Designer will handle those actions appropriately.
However, if after creating the project, you immediately rename Form1.cs and its counterparts to, say, MyForm.cs, etc. and then drag items from the toolbox to the form or select the form and use the properties window to add event handlers, the Designer does not appropriately update the renamed form files or form design.
What I have to do is use the original Form1 files, add the tools and event handlers, and build the application. After that, I can rename the files and they still work.
Is there a way to fix the problem of renaming first?
Hi nick1941,
Thanks for posting your issue here.
However this platform is used for how-to discussions and sharing best practices for building any app with .NET.Since your issue is a technical question, welcome to post it in Microsoft Q&A forum, the support team and communities on Microsoft Q&A will help you for any technical questions.
Besides, it will be appreciated if you can share it here once you post this technical question Microsoft Q&A.
Best Regards,
Lan Huang
- djQueckeCopper ContributorI finally gave up. Every time I tried to rename Form1 it has destroyed my project. You can't even rename it upon it being created. I've considered trying to built my own template but haven't had the time.
Good Luck - LanHuang
Microsoft
Hi nick1941,
Thanks for posting your issue here.
However this platform is used for how-to discussions and sharing best practices for building any app with .NET.Since your issue is a technical question, welcome to post it in Microsoft Q&A forum, the support team and communities on Microsoft Q&A will help you for any technical questions.
Besides, it will be appreciated if you can share it here once you post this technical question Microsoft Q&A.
Best Regards,
Lan Huang- nick1941Copper ContributorHi LanHuang,
I tried posting this question to Microsoft Q&A twice, but it was deleted due to "violating community standards". I didn't see anything in the post that would offend anyone. Before I resubmit it to Q&A, perhaps you could look at it and tell me if there's something I should correct to avoid that issue.
Thanks,
nick1941