AutoScroll
All Wisej.NET containers can scroll their content when AutoScroll is true. The default is false, which clips content that extends beyond the container. When AutoScroll is enabled, Wisej.NET shows or hides scrollbars as needed, subject to the ScrollBars setting.
ScrollBars
When AutoScroll is true, use ScrollBars to control which scrollbars can appear:
- Both (Default). Horizontal and Vertical Scrollbars are shown or hidden as needed.
- None. Scrollbars are never displayed, similar to setting AutoScroll = false.
- Horizontal. Only the horizontal scrollbar is shown if needed.
- Vertical. Only the vertical scrollbar is shown if needed.
- Hidden. The scrollbars are never shown but touch scrolling and wheel scrolling are supported. It's usually used for mobile apps when the scrollbars should not be visible.
When in design mode and AutoScroll is true, both scrollbars are always visible regardless of the ScrollBars property.
The browser will always scroll a widget into view when it receives the focus, regardless of the scrollbar settings.
Use HorizontalScroll.Visible and VerticalScroll.Visible to check whether the respective scrollbars are visible.
Scroll Position
Regardless of the AutoScroll and ScrollBars properties, Wisej.NET applications can read or set the scroll position (forcing a scroll) of the container using the VerticalScroll.Value and HorizontalScroll.Value properties.
- C#
- VB.NET
// Scroll the content up to 50 pixels.
// The final scroll amount is limited by the size of the view port (scroll area)
private void button1_Click(object sender, EventArgs e)
{
this.VerticalScroll.Value = 50;
}
' Scroll the content up to 50 pixels.
' The final scroll amount is limited by the size of the view port (scroll area)
Private Sub Button1_Click(sender As Object, e As EventArgs)
Me.VerticalScroll.Value = 50
End Sub
Scroll Area & Margins
The scrolling area is calculated to fit the content. To add space below or to the right of the content, set AutoScrollMargin, as shown in the following examples.
-34aa2565204ecbdbf37291c55f62f8ef.png)
-4e1fdd9efb164f52914f966de7fa9481.png)
You can also set a minimum size for the viewport (the scrolling area) to make the container scroll the content regardless of the space occupied by the child controls.
-fcfddce442a89b4d7f8769f64e9895a2.png)
Scroll Event
The Scroll event is one of the lazy events (fired only if there is a handler attached). When you handle the event, Wisej.NET will fire it every time the scroll position of either scroll bars (even if set to Hidden) changes.
In the event handler, you can check both the e.OldValue and e.NewValue to determine if the scrollbar was moved up or down, or the e.ScrollOrientation to determine if the Scroll event was fired by the horizontal or vertical scrollbar.
You can also use the e.Type enumeration to determine if the scroll position changed because of a Decrement scroll, an Increment, or if the scroll position was dragged to the First (top or left) position or to the Last (bottom or right) position.
Touch Scrolling
Wisej.NET fully supports touch scrolling and inertia scrolling. When the user swipes a touch device it will initiate the inertia scrolling which will keep scrolling and firing the Scroll event while it slows down.
If the user touches the scroll bar, the scrolling system will NOT process the touch and inertial scrolling and will instead move the scrollbar as the user drags the scrolling knob.
Right to Left Support
When RightToLeft is true, the vertical scrollbar and the corner grip are automatically moved to the left. This is separate from the mirroring feature, which "flips" the layout of the child controls. See Right To Left support.
-5f0638433fcd481834956d98e7f99df0.png)