user13700937
user13700937

Reputation:

Is there any way to NOT get a Designer error when deleting code? (C#, Visual Studio, WinForms)

I'm making a WinForms program for my Diploma final project using C# and Visual Studio.

Sometimes I accidentally double-click a tool and that opens up the main event for the tool, like button_Click. But when I delete that code and check the Designer, it gives me an error message. If I choose to ignore it, all of the Form's formatting is lost and I have to start over (real pain in the a**).

I usually just click the - to minimise the code block and then add comments that the code is unused. But as you can guess, this makes for a really ugly and unorganised coding page.

Is there any way for me to remove the code and not get a Designer error?

Upvotes: 3

Views: 1054

Answers (1)

Jeremy Thompson
Jeremy Thompson

Reputation: 65604

Go to the Form.Designer.cs file or F12 on the InitializeComponent() method.

Then on the right margin look for the red dots and delete the events pointed to methods that have been deleted.

Anyone got a quicker way?

Upvotes: 5

Related Questions