Wednesday 15 June 2011

winforms - Remove unused C# code in Visual Studio -



winforms - Remove unused C# code in Visual Studio -

when working on windows form have accidently clicked on buttons , have part of code related click event. don't need them , remove these parts code but, if do, visual studio complains when compiling cause search missing code. how can rid of unused click events on code?

when double-click on control, default event gets wired , stubbed out handler gets created you.

the stubbed handler know saw , deleted.

private void button1_click(object sender, eventargs e) { }

the other piece event gets wired. compile error comes from. deleted event handler, did not remove event subscription.

this can found in designer.cs file attached specific form.

private void initializecomponent() { this.button1 = new system.windows.forms.button(); this.suspendlayout(); // // button1 // this.button1.name = "button1"; //this line has compile error. this.button1.click += new system.eventhandler(this.button1_click); }

as mentioned in comments, can go event properties command , reset event, can go designer , remove invalid line. using reset command remove stub , event subscription.

c# winforms visual-studio mouseclick-event

No comments:

Post a Comment