What events are triggered when ShowDialog(ParentForm) is called in C#

You can override the OnVisibleChanged method in your settings form. Make sure to call base.OnVisibleChanged though as to not screw up any potential observers of the event (and anything else the base class may do inside of that method.)


FormShown event - raised only once when form is displayed first time. OnPaint / OnActivate - every time form is activated, but these events raised even when you switch with other application, which probably you don't want to do. If you are changing form visbility, then you can use OnVisibleChanged If you are minimizing the form, you can use OnSizeChanged / OnLocationChanged event.

If none suits you, make a public property and set false when form is closed / hidded, and set true before showing it. OnActivate, use this property to do your task.

Tags:

C#

Winforms