Difference between Resize and SizeChanged events

Haider Ali Wajihi picture Haider Ali Wajihi · Sep 16, 2011 · Viewed 35.2k times · Source

In C# .Net in Winforms, I found two events in almost all components, Resize() and SizeChanged(). Is there any difference between them? If both events are the same then why has C# provided two different events?

I am creating a user control in C#. This control contains a text box. I want to resize the textbox when the user changes the control's size. I am confused about which event I should use and why?

Answer

Guffa picture Guffa · Sep 16, 2011

The Resize event occurs when the control is resized, while the SizeChanged event occurs when the Size property changes.

You could use either, as a resize will cause the Size property to change. However, you should rather use the Layout event, as recommended both in the documentation for the Resize and SizeChanged events.