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

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

# TextAlignment (enum)

The text alignment regarding the anchor point.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public enum TextAlignment
```

## Examples

C#:

```csharp
using cAlgo.API;

namespace cAlgo
{
    // This sample indicator shows how to use TextAlignment property to align the text
    public partial class TextAlignmentSample : Indicator
    {
        protected override void Initialize()
        {
            var stackPanel = new StackPanel
            {
                BackgroundColor = Color.Gold,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Opacity = 0.6,
                Width = 200
            };

            stackPanel.AddChild(new TextBlock { Text = "Sample text", TextAlignment = TextAlignment });

            Chart.AddControl(stackPanel);
        }

        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
        stackPanel.Width = 200

        textBlock = TextBlock()
        textBlock.Text = "Sample Text"
        textBlock.TextAlignment = api.TextAlignment

        stackPanel.AddChild(textBlock)

        api.Chart.AddControl(stackPanel)
```

config.json:

```json
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "IsOverlay": true,
  "Parameters": [
    {
      "Name": "TextAlignment",
      "DisplayName": "Text Alignment",
      "Type": "Enum",
      "EnumTypeFullName": "cAlgo.API.TextAlignment",
      "DefaultValue": "Center"
    }
  ]
}
```

## Values

- `TextAlignment.Left` — Align the text left.
- `TextAlignment.Right` — Align the text right.
- `TextAlignment.Center` — Center the text vertically.
- `TextAlignment.Justify` — Justify the text.

