Search code examples
c#winformsuser-controls

Difference between Resize and SizeChanged events


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?


Solution

  • 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.