Sometimes these answers only come from the source code:
SizeChanged
The SizeChanged
event is raised by the OnSizeChanged()
. This function is in turn only called by UpdateBounds()
, which is called by several mechanisms, primarily including the handling of WM_MOVE
and WM_WINDOWPOSCHANGED
messages.
Again from the source, OnSizeChanged()
will only be called when UpdateBounds()
has determined that there is a difference between the old size and new size. So, yes, as the others have already determined, the SizeChanged
event corresponds to the Size
property changing.
Resize
The Resize
event is different, but not by much. It is raised by OnResize()
. This function is called as a direct result of OnSizeChanged()
. However, the reverse is not true. That is to say, OnResize()
DOES NOT call OnSizeChanged()
.
The difference lies in the perspective from which you uses these API's. If you are merely subscribing to these events, then there is virtually no difference. Either way you look at it, whenever the control's size is changed, both events fire.
However, if you are inheriting Control
, one must be aware of the following differences:
The reason why one might care, for instance, is to make sure that their logic is executed before the base implementation (and hence before the invalidate) to be properly drawn to the screen.
LocationChanged and Move
These are two move events that parallel SizeChanged
and Resize
almost identically. The exceptions are that OnMove()
only invalidates when the style, ControlStyles.SupportsTransparentBackColor
is true and the backcolor is a less than opaque alpha value. And, OnMove()
will not trigger a layout.
Again this difference likely only matters to control authors.
Conclusions
After investigating into the source code, my conclusion is that the Resize
and Move
events are an abstraction away from the property changed events, and would likely be the preferred choice for both subscribing and overriding these specific events.
As others mention, the Layout
event and OnLayout()
function are also a decent choice; however, layouts can occur in many instances:
- When child controls are added/removed.
- When the bounds of the control changes.
- When other changes occur that can affect the layout of the control.
Side Note: "Other changes" is vague, but I assume that Microsoft is referring any action taken by inheritors that require a layout.
Relying too strongly on layout events may slow down your code/control since they will occur more frequently than a simple resize event would. Or, it is possible that the layout engine might be suspended by SuspendLayout()
, In this case, you will not be able to react to size changes via the Layout
event.