Search code examples
c#winformsuser-controlsscrollbar

event when the scroll bars appear C#


How can you detect exactly when the scroll bar appears in a UserControl? Is there an event for this?


Solution

  • I ended up using the Layout event, and checking if the scrollbars were currently shown or not. A Layout event is sent when the scroll bar visibility changes.

    This is more reliable than listening to the size of the window, because the size of the window is not the only thing that can cause the scrollbars to appear.

    https://msdn.microsoft.com/en-us/library/system.windows.forms.control.layout(v=vs.110).aspx