The Form class provides several events that fire when certain form properties change. The name of each of these events has the form PropertyNameChanged where PropertyName is the name of the corresponding property. For example, the BackColorChanged event fires when the form’s BackColor property changes.
The following is a list of these events.
BackColorChanged MaximumSizeChanged BackgroundImageChanged MinimumSizeChanged ContextMenuChanged ParentChanged CursorChanged SizeChanged DockChanged StyleChanged EnabledChanged SystemColorsChanged FontChanged TextChanged ForeColorChanged VisibleChanged LocationChanged
The names of most of these controls are self-explanatory, so they are not described further here. The exception is the SystemColorsChanged event. This occurs when the system’s colors are changed either by the user or programmatically.
For example, suppose that you want the form to draw using its ForeColor property and you want that property to match the active title bar text color. Then, you could use the following code to update ForeColor when the user changed the system colors:
Private Sub Form2_SystemColorsChanged(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.SystemColorsChanged Me.ForeColor = SystemColors.ActiveCaptionText End Sub
Note that Visual Basic invalidates the form after raising the SystemColorsChanged event, so the form immediately repaints itself using the new settings.