I have a Windows Forms application. I have several forms in this application (the main form and several specialized forms), and on only one form, click events do not fire for any of my buttons.
It's not that the code in the handler does not work. This may be due to the fact that a breakpoint in the first line of the handler is never reached when a button is pressed.
Other events work (I use CheckedChanged events in this form and they behave).
My team members reviewed, and also cannot identify the problem.
Here is a simplified view of my code:
Designer Generated Code
partial class MyForm { private System.Windows.Forms.Button addButton; private void InitalizeComponent() { this.addButton = new System.Windows.Forms.Button(); this.addButton.Name = "addButton";
My code
public partial class MyForm : Form { public MyForm() { InitializeComponent(); } private void addButton_Click(object sender, EventArgs e) { MessageBox.Show("The debugger is not reaching a break point on this line"); } }
Change: additional information from testing
In my form, there are several data-related drop-down lists. I found that the click event does not fire only if I first make a selection from the drop-down list.
If I do not make a choice, the breakpoint in the button handler fires. Otherwise, it is not. There are no registered events in these drop-down lists.
source share