Is there any way to disable this functionality (double-clicking of components to generate an Event Handler)

It seems to be a bit "trigger happy" at times, especially in forms with alot of controls, where you single click something (like a tabcontrol) and it already generates an event handler. I'd prefer having to doubleclick the appropriate event in the event list rather than spending alot of time cleaning up useless event handlers every time ;)

Thanks in advance.

Re: Windows Forms Designer Double-click event handler generation in Form Designer

Philip Wright

As far as I know there is no mechanism to turn this off across the whole designer. The designer generates a handler for the event that is specified using the DefaultEvent attribute that is applied to each of the controls in Windows.Forms. I guess you could derive a new class from each of the builtin controls and then set this attribute to something that does not exists. That would prevent the designer from generating anything because it would not be able to find the defined event.

Of course, it requires you to derive a new class from each of the existing ones and then using those derived classes in your applications. Actually that is not a bad idea anyway as you never know in the future if you want to add some extra functionality across your controls. In which case being able to update your own derived classes makes it a quick and painless processs.

Phil Wright
Free user interface controls for Windows.Forms

Re: Windows Forms Designer Double-click event handler generation in Form Designer

Eric Burcham

As is typical with new releases, this is of course a NEW problem that did not occur in VS 2003. It still works just fine all the time.

Has anyone acknowledged this as a bug For instance:

Expected Behaviour:
When editing a control property in the Windows Forms Designer in Visual Studio 2005, and then clicking the form being edited, or a control therein, the newly selected item should be selected.

Observed Behaviour:
Instead, upon clicking the new control, the default Event Handler for that control is generated, and the code editor opens with the focus inside the newly generated event handler. This should only occur when double-clicking a control in the Windows Forms Designer.

Steps to Reproduce:
1) Open Visual Studio 2005
2) Create a new Windows Forms Application
3) Add a TextBox and a Button to the Form from the Tool Box
4) Edit the Text Property of the TextBox using the Properties window
5) Immediately click on the button

Result: The Button's _Click event handler is generated and opened in the code editor