---
name: "ctrlSetTextSelection"
type: command
status: ok
groups: ["GUI Control"]
arma3_since: "2.00"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/ctrlSetTextSelection
revid: 309239
updated: 2022-05-04T10:30:57Z
---

# ctrlSetTextSelection

*Command · GUI Control · Arma 3 v2.00*

## Description

Selects `length` characters of edit control from the `start` position and places cursor at the end of selection.

> [!NOTE]
> To only move the cursor, set *length* to 0. To select text from right to left, use negative *length* (See [ctrlTextSelection](../commands/ctrlTextSelection.md) for more info)

## Syntax

```sqf
control ctrlSetTextSelection [start, length]
```

**Parameters:**

- `control`: [Control](../topics/Control.md)
- `start`: [Number](../topics/Number.md) - selection start position
- `length`: [Number](../topics/Number.md) - length of characters to select (0 to only move the cursor). Negative length will select text from right to left (see example 3)

**Returns:** [Nothing](../topics/Nothing.md)

## Examples

### Example 1

```sqf
_control ctrlSetTextSelection [5, 10];
```

### Example 2

```sqf
disableSerialization;
private _ctrl = findDisplay 46 createDisplay "RscDisplayEmpty" ctrlCreate ["RscEditMulti", -1];
_ctrl ctrlSetPosition [0,0,0.5,0.3];
_ctrl ctrlCommit 0;
_ctrl ctrlSetText "Hello World";
_ctrl ctrlSetTextSelection [6, 5]; // selects World
ctrlSetFocus _ctrl;
```

### Example 3

Select text from right to left:

```sqf
_control ctrlSetTextSelection [5, -4];
```

## See also

[ctrlTextSelection](../commands/ctrlTextSelection.md) · [ctrlSetText](../commands/ctrlSetText.md)

<sub>Source: [BI Community Wiki — ctrlSetTextSelection](https://community.bistudio.com/wiki/ctrlSetTextSelection) (revision 309239).</sub>
