> For the complete documentation index, see [llms.txt](https://xojo.gitbook.io/add-ons/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xojo.gitbook.io/add-ons/stackview/version-3/details/scrollcontroller.md).

# ScrollController

{% hint style="info" %}
Class (inherits from [DesktopContainer](https://documentation.xojo.com/api/user_interface/desktop/desktopcontainer.html))
{% endhint %}

## Methods

| [AddView](#addview)                     | [Expand](#expand) |
| --------------------------------------- | ----------------- |
| [GetViews](#getviews-as-viewcontroller) | [Init](#init)     |
| [RemoveView](#removeview)               |                   |

### AddView(view As [ViewController](/add-ons/stackview/version-3/details/viewcontroller.md), index As [Integer](https://documentation.xojo.com/api/data_types/integer.html) = -1)

Adds a View (dynamically at the Runtime) to the StackView.

**Parameters**

<table><thead><tr><th width="150">Name</th><th width="150">Datatype</th><th width="414.8">Description</th></tr></thead><tbody><tr><td><em>view</em></td><td><a href="/pages/KJZWfOlCYcRN3xtksGkp">ViewController</a></td><td>Pointer to the View which should be added to the StackView.</td></tr><tr><td><em>index</em></td><td><a href="https://documentation.xojo.com/api/data_types/integer.html">Integer</a> = -1</td><td>Position to add the View into the StackView.</td></tr></tbody></table>

### Expand(value As [Boolean](https://documentation.xojo.com/api/data_types/boolean.html))

Expand or collapse the StackController.

**Parameters**

<table><thead><tr><th width="150">Name</th><th width="150">Datatype</th><th width="450.5207756232687">Description</th></tr></thead><tbody><tr><td><em>value</em></td><td><a href="https://documentation.xojo.com/api/data_types/boolean.html">Boolean</a></td><td>A Boolean specifiying the state of the <a href="/pages/-LMJNJAHEjHD4ToJEIAU">StackController</a>.</td></tr></tbody></table>

**Sample Code**

Button1 `Pressed`-Event:

{% code title="Pressed-Event" %}

```xojo
MyScrollController1.Expand(True)
```

{% endcode %}

### GetViews As [ViewController()](/add-ons/stackview/version-3/details/viewcontroller.md)

Returns an Array of the StackViews Views.

### Init(stackView As [StackController](/add-ons/stackview/version-3/details/stackcontroller.md), useAnimation As [Boolean](https://documentation.xojo.com/api/data_types/boolean.html) = [True](https://documentation.xojo.com/api/language/true.html))

Creates a new ScrollContainer starting with the given Parameters.

**Parameters**

<table><thead><tr><th width="192.91780821917806">Name</th><th width="152.89593163170562">Datatype</th><th width="330">Description</th></tr></thead><tbody><tr><td><em>stackView</em></td><td><a href="/pages/6J5jlv8tl3mtSSxKeo0x">StackController</a></td><td>Pointer to the <a href="/pages/6J5jlv8tl3mtSSxKeo0x">StackController</a>.</td></tr><tr><td><em>useAnimation</em></td><td><a href="https://documentation.xojo.com/api/data_types/boolean.html">Boolean</a> = True</td><td>Set Animation of the <a href="/pages/-LMJNJAHEjHD4ToJEIAU">StackController</a>.</td></tr></tbody></table>

**Sample Code**

MyScrollContainer1 `Opening`-Event:

{% code title="Opening-Event" %}

```xojo
If Not Self.AutoSetup Then
  Init(MyStackView1)
End If
```

{% endcode %}

### RemoveView(index As [Integer](https://documentation.xojo.com/api/data_types/integer.html) = - 1)

Removes a View from the StackView.

**Parameters**

<table><thead><tr><th width="150">Name</th><th width="150"></th><th width="447.7113523027281">Description</th></tr></thead><tbody><tr><td><em>index</em></td><td><a href="https://documentation.xojo.com/api/data_types/integer.html">Integer</a> = -1</td><td>Removes the View at position index from the StackView.</td></tr></tbody></table>

## Properties

### AutoSetup As [Boolean](https://documentation.xojo.com/api/data_types/boolean.html) *(designtime-only)*

Automatically adds the StackController contained in the ScrollController. Otherwise, you must add the StackController manually via [`Init`](#init-stackview-as-stackcontroller-useanimation-as-boolean-true) in the `Opening` -Event.

{% hint style="info" %}
If  `AutoSetup = True`, the views are arranged according to their *DesktopContainer.TabIndex* set in the Xojo IDE.
{% endhint %}

### Expanded As [Boolean](https://documentation.xojo.com/api/data_types/boolean.html) *(read-only)*

Returns the state of the StackController.

### UseAnimation As [Boolean](https://documentation.xojo.com/api/data_types/boolean.html)

The animation state of the StackController.

{% hint style="info" %}
The StackView Classes are able to shown within a [NSScrollView](https://developer.apple.com/documentation/appkit/nsstackview). This feature is macOS-only and there is no guarantee that the feature will work in coming Versions of Apple’s macOS. StackView uses the [XScrollView](https://www.pidog.com/share/nsscrollview.xojo_binary_project.zip) class of Jim McKay from [piDog Software](https://www.pidog.com).
{% endhint %}
