Peter Davis
Peter Davis

Reputation: 41

Is there a way to not auto-generate the click event logic when a control is double-clicked in the Windows Forms designer?

Occasionally I will double-click a control on accident when moving them around in the designer. This creates a click event method in the associated class file along with the designer file. This can be undone, but ctrl+z seems to go back a step or two too far in the designer and is a minor nuisance. I don't have much need for the double-click shortcut and would prefer it removed entirely. Any advice is appreciated.

Upvotes: 3

Views: 164

Answers (1)

LarsTech
LarsTech

Reputation: 81610

Probably not worth the effort, but you could just inherit from the control you are using and set the DefaultEvent attribute to nothing. For example:

[DefaultEvent("")]
public class ButtonEx : Button {

}

Now when you double-click on a ButtonEx control on the form in the designer, nothing happens.

Upvotes: 3

Related Questions