---
id: "M:cAlgo.API.ToggleButton.#ctor"
kind: "constructor"
type: "T:cAlgo.API.ToggleButton"
url: "https://help.ctrader.com/ctrader-algo/references/Controls/ToggleButton/Constructor/"
---

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

# ToggleButton constructor

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

## ToggleButton()

Initializes a new instance of the Toggle button 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.

C#:

```csharp
public ToggleButton()
```

Python:

```python
ToggleButton()
```

### Examples

C#:

```csharp
var toggleButton = new ToggleButton { Text = "Auto trading", IsChecked = true };
toggleButton.Click += args => Print("Auto trading: {0}", args.ToggleButton.IsChecked);
Chart.AddControl(toggleButton);
```

Python:

```python
toggleButton = ToggleButton()
toggleButton.Text = "Auto trading"
toggleButton.IsChecked = True
toggleButton.Click += lambda args: api.Print(f"Auto trading: {args.ToggleButton.IsChecked}")
api.Chart.AddControl(toggleButton)
```

