0

this problem is annoying me and I took too much time to get it.

I'm very new to WinForms, so, maybe I'm missing something.

Whenever I drag'n'drop my UserControl to the form, it's Load event is being called (not the constructor).

it is very easy to reproduce.

Edit: I'm using .net core 3.1

1 - Create a new Project

2 - Create a new UserControl

3 - Add a Load Event and force an exception inside this method

4 - Build and try to add the control to the mainForm, the exception will raise.

The method is being called even with my project stoped.

For now, I just comment the method, build and add the Control to my forms, then I uncomment again and evertything works normally. There is no exception in Runtime and I can see the control in the desing. The only problem is to drag it to the form.

enter image description here

enter image description here

enter image description here

William Borgo
  • 394
  • 2
  • 11
  • 1
    Yes, it is suppost to happen. The UC is operating in design mode only when you are actually modifying its content with the designer, when you drop it on a form then it works like any other control in the toolbox. https://stackoverflow.com/questions/336817/how-can-i-detect-whether-a-user-control-is-running-in-the-ide-in-debug-mode-or – Hans Passant Aug 28 '22 at 17:30
  • Oh, thank you! That was very strange to me, I thought the Events rans only in Runtime. – William Borgo Aug 28 '22 at 18:32

0 Answers0