Reputation: 1
I have a project with multiple forms. After some changes to the project dataset, Load event on one form stopped working (although form shows correctly). There were no changes to the form itself. As a quick workaround I've created Shown handler (through VS IDE) and put my code there, but it's not firing either (I've created test message boxes to be sure it isn't a problem with debugger).
On the other hand many events do work, e.g. I've tried Activated and it works but it's not useful for me.
There is appropriate line in .Designer.cs:
this.Load += new System.EventHandler(this.FormZlecenie_Load);
I've compared three files connected with this form (.cs, .resx, .Designer.cs) with backup that I've made before changes to the dataset and there are virtually no differences (and backup works without problems).
I don't want to revert to backup because I need these changes in dataset and there are many.
I've also deleted all binary folders (bin, obj) but without success.
I've looked for similar problems on the net but the only solution I've found was to re-create the form. This is the last resort for me because it will be rather time-consuming and I don't like to give up so easily.
So where else should I look? I'm out of ideas.
Upvotes: 0
Views: 5942
Reputation: 11
Look at the bindings in your code. Sometimes events are omit when bindings are wrong (i.e. binding to Thread.IsAlive - my case).
Upvotes: 1
Reputation: 584
Check for the call of InitializeComponent();
in the constructor of the forms class.
The form partially still works without the call. Even some form specific events get called. But the controls on the form won’t be created and events like the this.Load
don’t work anymore.
Upvotes: 0
Reputation: 2983
I would go into the form designer and ensure that the event shows up in the property window. If it is there, then remove it, build your project, then re-add it again manually.
If this doesn't work, go into the constructor for the form and register the event manually using the code sample you gave in your question. Debug to see if the event fires.
Next, try using a different method for the event handler. Just the one that is auto generated when you use "this.load +=".
Finally, worst case scenario you could recreate the form and copy over the elements from the current form over. Sometimes the designer screws up the form and can't fix itself.
Hope this helps!
Upvotes: 1