---
id: "P:cAlgo.API.TextBox.MaxLength"
kind: "property"
type: "T:cAlgo.API.TextBox"
url: "https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/MaxLength/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# TextBox.MaxLength

Member of [TextBox](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/index.md).

## MaxLength

Gets or sets the maximum number of characters that can be manually entered into the text box.

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Accepted without error but never displayed, so control events such as Click are never raised.
- Cloud: Accepted without error but never displayed, so control events such as Click are never raised.

C#:

```csharp
public int MaxLength {get; set;}
```

Python:

```python
textBox.MaxLength: int
```

### Returns

`int` — 

### Examples

C#:

```csharp
var labelTextBox = new TextBox { MaxLength = 20, Width = 150 };
Chart.AddControl(labelTextBox);
Print("Maximum label length: {0}", labelTextBox.MaxLength);
```

Python:

```python
labelTextBox = TextBox()
labelTextBox.MaxLength = 20
labelTextBox.Width = 150
api.Chart.AddControl(labelTextBox)
api.Print(f"Maximum label length: {labelTextBox.MaxLength}")
```

