Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
Not really doing Windows software these days but... An old habit I have from VB6 (!) is to use the convention btn, txt & on for naming things on a form. VS2008 didn't have an issue, time moves on, VS2022 I was writing a quick and dirty program to display Hex value of integers in a file (long story why)
Drag a Button over, not really paying sufficient attention, name the button btnTest, look at the error list
Quote:
Severity Code Description Project File Line Suppression State
Message IDE1006 Naming rule violation: These words must begin with upper case characters: btnTest2_Click WinFormsApp1 C:\Users\glenn.patton\OneDrive - Limbs and Things Ltd\Desktop\WinTest\WinFormsApp1\Form1.cs 15 Active

W.T.F. rename btnTest2 to BtnTest2 in the code then switch to form to rename and get:
Quote:


To prevent possible data loss before loading the designer, the following errors must be resolved:



With no way to get to the form whats happened???

What I have tried:

The Form has gone the program was a quick and dirty three minute job, I have tried clicking on Show Designer just get the same thing, almost like the form has got lost.
Posted
Comments
0x01AA 7-Mar-24 17:46pm    
You forgot to show the exact error messag in the 'W.T.F.' section :-)
Now most probably you renamed the button while a button click method was allready existing. And looks like VS is still not able to adjust the VS created code behind :(
Richard MacCutchan 8-Mar-24 3:53am    
See my updated Solution below.

See Code analysis in .NET | Microsoft Learn[^]

You can manually edit the Form design. Go to the folder with your project files and find the one with the name of your form, and the extensions designer.vb. Load that up into notebook or your favourite editor and make the required changes. You should now be able to open your project in Visual studio as normal.
 
Share this answer
 
v3
Rename the button in the UI first, then you can rename anything you need to in the code.

To fix this, you can just click the "View Code" link in the broken designer window and manually make the changes in the designer code to correct the names of the controls.

As to the naming conventions changing, yeah, those have changed. Hungarian Notation isn't really a thing anymore.
 
Share this answer
 
Comments
glennPattonWork3 7-Mar-24 19:20pm    
Nutz! :) , I can't seem to open the form anymore.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900