Winforms designer - generated code is not removed

Take a windows form, add as button on it.
Double click the button.

The click method is generated and the handler is added to the designer file.
Remove the click method and compile - cannot compile because the handler was not removed (and it should, as it is in the designer.pas where we are not supposed to edit).

Hmm. As far as I recall, WinForms never removes event handle methods, as they could contain user code. And haik *unlike Delphi), it also doesn’t remove empty ones. So that seems as designed, unless I;m missing something?

Do the Scenario in MS VB.Net - no problems.
Do the scenario in MS C# - no problems
Do the scenario in Oxygene - you have to remove some code from the designer by hand before it can compile.

Thanks, logged as bugs://80391

This would be solved with the ExposeEvents and Handles that we spoke about; because with this the event handler does not have to be wired in code anymore, leaving no code to remove in this case.

Yeah, but that’s orthogonal really. We gotta fix this to work properly with either scenario.

Hello Theo,

Could you please give me the video on how to reproduce the issue. I have tried next steps with MS C#:

  1. Added new button - dblclik - the empty button1_Click handler was added. Remove the button1_Click event from Events property page - the handler as removed.
  2. Added empty handler again and types some code inside it. Removing the event on Events property page didn’t remove the handler from code.
    Then I tried to do the same steps with RemObjects Oxygene Winforms project, and got the same behavior.

Best regards.

You are right - I was wrong.

  In MS C      # is has the same behavior.

  In VB it has not.

Curious.

I’d say lets call this “as designed” then.

Agreed.

1 Like

bugs://80391 got closed with status nochangereq.