Load event gets fired on each call to ShowDialog()

While chasing down one bug in my custom message box at codeproject I came acorss an interesting fact. If you use ShowDialog() to show your form then the Load event gets fired everytime. I've been using Winforms for such a long time and was surprised that I had never really come across this behaviour.

It's not a bug, if you use reflector and take a look at Form.ShowDialog() you will see that the flag which is used to prevent Load event from getting fired more than once is disabled everytime ShowDialog() gets called.

No Comments