---
id: "E:cAlgo.API.Button.Click"
kind: "event"
type: "T:cAlgo.API.Button"
url: "https://help.ctrader.com/ctrader-algo/references/Controls/Button/Click/"
---

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

# Button.Click

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

## Click

Occurs when the button is clicked.

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 event Action<ButtonClickEventArgs> Click;
```

Python:

```python
button.Click += handler  # handler(obj: ButtonClickEventArgs)
```

### Returns

`Action<ButtonClickEventArgs>` — 

### Examples

C#:

```csharp
var button = new Button { Text = "Buy 0.01 lots" };
button.Click += args =>
{
    var result = ExecuteMarketOrder(TradeType.Buy, SymbolName, Symbol.QuantityToVolumeInUnits(0.01), "Button");
    Print("{0} clicked, order successful: {1}", args.Button.Text, result.IsSuccessful);
};
Chart.AddControl(button);
```

Python:

```python
def on_start(self):
    button = Button()
    button.Text = "Buy 0.01 lots"
    button.Click += self.on_button_click
    api.Chart.AddControl(button)

def on_button_click(self, args):
    result = api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, api.Symbol.QuantityToVolumeInUnits(0.01), "Button")
    api.Print(f"{args.Button.Text} clicked, order successful: {result.IsSuccessful}")
```

