# AutoScroll

All Wisej.NET containers can scroll their content when the **AutoScroll** property is set to *true* (default is *false* - the content is truncated). When AutoScroll is *true*, Wisej.NET automatically shows or hides the horizontal or vertical scroll bars, unless the property [**ScrollBars** ](#scrollbars)has a value different than *Both*.

## ScrollBars

Once **AutoScroll** is true, and the container is able to scroll its content, you can control which scrollbar is visible by setting the **ScrollBars** property:

* **Both (Default)**. Horizontal and Vertical Scrollbars are shown or hidden as needed.
* **None**. Scrollbars are never displayed, it's 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 is supported. It's usually used for mobile apps when the scrollbars should not be visible.

{% hint style="info" %}
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.
{% endhint %}

Check whether the horizontal scrollbar using the **HorizontalScroll.Visible** property, and if the vertical scrollbar is visible using the **VerticalScroll.Visible** property.

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

{% tabs %}
{% tab title="C#" %}

```csharp
// 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;
}
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
' 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
```

{% endtab %}
{% endtabs %}

## Scroll Area & Margins

The scrolling area is calculated to fit the content exactly. If you want to add some margin at the bottom or to the right of the content, use the

![Form with AutoScroll = true and no AutoScrollMargin](https://553579532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF1D11gPs_az3xaKusw%2Fuploads%2Fgit-blob-153a7dfb6c9b36ae329a9d37459bd620d51d61d0%2Fimage.png?alt=media)

![Form with AutoScroll = true and AutoScrollMargin set to 50,50 pixels](https://553579532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF1D11gPs_az3xaKusw%2Fuploads%2Fgit-blob-bc7598ba157235a82221a19fd3d0b9d0ef173bdb%2Fimage.png?alt=media)

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.

![Form with AutoScroll = true and AutoScrollMinSize set to 1000,1000 pixels.](https://553579532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF1D11gPs_az3xaKusw%2Fuploads%2Fgit-blob-482f7013abf3a220ff179f6ee3138cec789cd5e3%2Fimage.png?alt=media)

## Scroll Event

The **Scroll** event is one of the [lazy events](https://docs.wisej.com/docs/controls/lazy-events#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.

{% hint style="info" %}
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.
{% endhint %}

## 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](https://docs.wisej.com/docs/concepts/righttoleft) support.

![](https://553579532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF1D11gPs_az3xaKusw%2Fuploads%2Fgit-blob-02622cbb0646aca6c5771ed6affb78cdb84d8538%2Fimage.png?alt=media)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/docs/controls/general/autoscroll.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
