---
id: "T:cAlgo.API.TextBox"
kind: "class"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/"
---

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

# TextBox (class)

Represents the text box class.

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.

## Definition

```csharp
public class TextBox : Control
```

## Examples

C#:

```csharp
using cAlgo.API;

namespace cAlgo
{
    // This sample indicator shows how to add a text box control on your chart
    public partial class TextBoxSample : Indicator
    {
        protected override void Initialize()
        {
            var stackPanel = new StackPanel
            {
                BackgroundColor = Color.Gold,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Opacity = 0.6,
            };

            var textBox = new TextBox
            {
                Text = "Enter text here...",
                FontWeight = FontWeight.ExtraBold,
                Margin = 5,
                ForegroundColor = Color.White,
                HorizontalAlignment = HorizontalAlignment.Center,
                Width = 150
            };

            textBox.TextChanged += TextBox_TextChanged;

            stackPanel.AddChild(textBox);

            Chart.AddControl(stackPanel);
        }

        private void TextBox_TextChanged(TextChangedEventArgs obj)
        {
            Print("Text box text changed to: ", obj.TextBox.Text);
        }

        public override void Calculate(int index)
        {
        }
    }
}
```

Python:

```python
import clr
clr.AddReference("cAlgo.API")

from cAlgo.API import *

class Test():
    def initialize(self):
        stackPanel = StackPanel()
        stackPanel.BackgroundColor = Color.Gold
        stackPanel.HorizontalAlignment = HorizontalAlignment.Center
        stackPanel.VerticalAlignment = VerticalAlignment.Center
        stackPanel.Opacity = 0.6

        textBox = TextBox()
        textBox.Text = "Enter text here..."
        textBox.FontWeight = FontWeight.ExtraBold
        textBox.Margin = Thickness(5)
        textBox.ForegroundColor = Color.White
        textBox.HorizontalAlignment = HorizontalAlignment.Center
        textBox.Width = 150

        textBox.TextChanged += lambda args: api.Print(f"Text box text changed to: {args.TextBox.Text}")

        stackPanel.AddChild(textBox)

        api.Chart.AddControl(stackPanel)
```

config.json:

```json
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "IsOverlay": true
}
```

## Constructors

- `public TextBox()` — Initializes a new instance of the TextBox class. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/Constructor/index.md)

## Properties

- `public bool AcceptsReturn {get; set;}` — Gets or sets a value that indicates how the text editing control responds when the user presses the ENTER key. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/AcceptsReturn/index.md)
- `public bool AcceptsTab {get; set;}` — Gets or sets a value that indicates how the text editing control responds when the user presses the TAB key. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/AcceptsTab/index.md)
- `public Color BorderColor {get; set;}` — Gets or sets the color of the text box border. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/BorderColor/index.md)
- `public Thickness BorderThickness {get; set;}` — Gets or sets the border thickness. Property value can be set using Thickness, number, or a string new Thickness(5), new Thickness(1, 2, 3, 4), 5, "5", "1 2 3 4". [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/BorderThickness/index.md)
- `public Color CaretColor {get; set;}` — Gets or sets the color of the insertion caret. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/CaretColor/index.md)
- `public CharacterCasing CharacterCasing {get; set;}` — Gets or sets whether the TextBox control modifies the case of characters as they are typed. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/CharacterCasing/index.md)
- `public ScrollBarVisibility HorizontalScrollBarVisibility {get; set;}` — Defines the horizontal scroll bar visibility. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/HorizontalScrollBarVisibility/index.md)
- `public bool IsReadOnly {get; set;}` — Gets or sets a value indicating whether the current text box is read-only. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/IsReadOnly/index.md)
- `public bool IsReadOnlyCaretVisible {get; set;}` — Gets or sets a value that indicates whether a read-only text box displays a caret. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/IsReadOnlyCaretVisible/index.md)
- `public int MaxLength {get; set;}` — Gets or sets the maximum number of characters that can be manually entered into the text box. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/MaxLength/index.md)
- `public int MaxLines {get; set;}` — Gets or sets the maximum number of visible lines. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/MaxLines/index.md)
- `public int MinLines {get; set;}` — Gets or sets the minimum number of visible lines. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/MinLines/index.md)
- `public Color SelectionColor {get; set;}` — Gets or sets the text color of the current text selection. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/SelectionColor/index.md)
- `public double SelectionOpacity {get; set;}` — Gets or sets the opacity of the selected text. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/SelectionOpacity/index.md)
- `public string Text {get; set;}` — Gets or sets the text. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/Text/index.md)
- `public TextAlignment TextAlignment {get; set;}` — Gets or sets a value that indicates the horizontal alignment of text content. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/TextAlignment/index.md)
- `public TextWrapping TextWrapping {get; set;}` — Gets or sets how the text box should wrap text. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/TextWrapping/index.md)
- `public ScrollBarVisibility VerticalScrollBarVisibility {get; set;}` — Defines the vertical scroll bar visibility. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/VerticalScrollBarVisibility/index.md)

## Events

- `public event Action<TextChangedEventArgs> TextChanged;` — Occurs when the text has changed. [details](https://help.ctrader.com/ctrader-algo/references/Controls/TextBox/TextChanged/index.md)

## Inherited members

- `public Color ForegroundColor {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/ForegroundColor/index.md)
- `public Color BackgroundColor {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/BackgroundColor/index.md)
- `public Thickness Padding {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/Padding/index.md)
- `public VerticalAlignment VerticalContentAlignment {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/VerticalContentAlignment/index.md)
- `public HorizontalAlignment HorizontalContentAlignment {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/HorizontalContentAlignment/index.md)
- `public FontWeight FontWeight {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/FontWeight/index.md)
- `public FontStyle FontStyle {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/FontStyle/index.md)
- `public string FontFamily {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/FontFamily/index.md)
- `public double FontSize {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/FontSize/index.md)
- `public void ResetProperty(ControlProperty property)` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/ResetProperty/index.md)
- `public Guid UniqueId {get;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/UniqueId/index.md)
- `public Style Style {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Style/index.md)
- `public double Left {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Left/index.md)
- `public double Top {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Top/index.md)
- `public double Right {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Right/index.md)
- `public double Bottom {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Bottom/index.md)
- `public double Width {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Width/index.md)
- `public double Height {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Height/index.md)
- `public double MinWidth {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/MinWidth/index.md)
- `public double MinHeight {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/MinHeight/index.md)
- `public double MaxWidth {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/MaxWidth/index.md)
- `public double MaxHeight {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/MaxHeight/index.md)
- `public bool IsEnabled {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/IsEnabled/index.md)
- `public bool IsVisible {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/IsVisible/index.md)
- `public double Opacity {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Opacity/index.md)
- `public Thickness Margin {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Margin/index.md)
- `public VerticalAlignment VerticalAlignment {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/VerticalAlignment/index.md)
- `public HorizontalAlignment HorizontalAlignment {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/HorizontalAlignment/index.md)
- `public Dock Dock {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Dock/index.md)
- `public bool IsHitTestVisible {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/IsHitTestVisible/index.md)

