---
id: "M:cAlgo.API.MessageBox.Show(System.String)"
kind: "method"
type: "T:cAlgo.API.MessageBox"
url: "https://help.ctrader.com/ctrader-algo/references/Controls/Windows/MessageBox/Show/"
---

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

# MessageBox.Show

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

## Show(string messageBoxText)

Shows a MessageBox with just a text

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

- CLI: Nothing is shown; Show returns MessageBoxResult.None immediately.
- Cloud: Nothing is shown; Show returns MessageBoxResult.None immediately.

C#:

```csharp
public static MessageBoxResult Show(string messageBoxText)
```

Python:

```python
MessageBox.Show(messageBoxText: str) -> MessageBoxResult
```

### Parameters

- `messageBoxText` (`string`, Python `str`): The text that will be displayed on MessageBox

### Returns

`MessageBoxResult` — MessageBoxResult

### Examples

C#:

```csharp
MessageBox.Show("Daily loss limit reached, trading is paused");
```

Python:

```python
MessageBox.Show("Daily loss limit reached, trading is paused")
```

## Show(string messageBoxText, string caption)

Shows a MessageBox with text and caption / title

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

- CLI: Nothing is shown; Show returns MessageBoxResult.None immediately.
- Cloud: Nothing is shown; Show returns MessageBoxResult.None immediately.

C#:

```csharp
public static MessageBoxResult Show(string messageBoxText, string caption)
```

Python:

```python
MessageBox.Show(messageBoxText: str, caption: str) -> MessageBoxResult
```

### Parameters

- `messageBoxText` (`string`, Python `str`): The text that will be displayed on MessageBox
- `caption` (`string`, Python `str`): The caption that will be displayed on MessageBox tile bar

### Returns

`MessageBoxResult` — MessageBoxResult

### Examples

C#:

```csharp
MessageBox.Show("Equity: " + Account.Equity, "Account status");
```

Python:

```python
MessageBox.Show(f"Equity: {api.Account.Equity}", "Account status")
```

## Show(string messageBoxText, string caption, MessageBoxButton button)

Shows a MessageBox with text, caption / title, and button

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

- CLI: Nothing is shown; Show returns MessageBoxResult.None immediately.
- Cloud: Nothing is shown; Show returns MessageBoxResult.None immediately.

C#:

```csharp
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button)
```

Python:

```python
MessageBox.Show(messageBoxText: str, caption: str, button: MessageBoxButton) -> MessageBoxResult
```

### Parameters

- `messageBoxText` (`string`, Python `str`): The text that will be displayed on MessageBox
- `caption` (`string`, Python `str`): The caption that will be displayed on MessageBox tile bar
- `button` (`MessageBoxButton`, Python `MessageBoxButton`): The button that will be displayed on MessageBox

### Returns

`MessageBoxResult` — MessageBoxResult

### Examples

C#:

```csharp
var result = MessageBox.Show("Open a buy position on " + SymbolName + "?", "Confirm order", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
    ExecuteMarketOrder(TradeType.Buy, SymbolName, Symbol.QuantityToVolumeInUnits(0.01));
```

Python:

```python
result = MessageBox.Show(f"Open a buy position on {api.SymbolName}?", "Confirm order", MessageBoxButton.OKCancel)
if result == MessageBoxResult.OK:
    api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, api.Symbol.QuantityToVolumeInUnits(0.01))
```

## Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon)

Shows a MessageBox with text, caption / title, button, and an image icon

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

- CLI: Nothing is shown; Show returns MessageBoxResult.None immediately.
- Cloud: Nothing is shown; Show returns MessageBoxResult.None immediately.

C#:

```csharp
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon)
```

Python:

```python
MessageBox.Show(messageBoxText: str, caption: str, button: MessageBoxButton, icon: MessageBoxImage) -> MessageBoxResult
```

### Parameters

- `messageBoxText` (`string`, Python `str`): The text that will be displayed on MessageBox
- `caption` (`string`, Python `str`): The caption that will be displayed on MessageBox tile bar
- `button` (`MessageBoxButton`, Python `MessageBoxButton`): The button that will be displayed on MessageBox
- `icon` (`MessageBoxImage`, Python `MessageBoxImage`): The icon that will be displayed on MessageBox

### Returns

`MessageBoxResult` — MessageBoxResult

### Examples

C#:

```csharp
if (Account.MarginLevel < 200)
    MessageBox.Show("Margin level is " + Account.MarginLevel + "%", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
```

Python:

```python
if api.Account.MarginLevel is not None and api.Account.MarginLevel < 200:
    MessageBox.Show(f"Margin level is {api.Account.MarginLevel}%", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning)
```

## Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)

Shows a MessageBox with text, caption / title, button, icon, and a default result

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

- CLI: Nothing is shown; Show returns MessageBoxResult.None immediately.
- Cloud: Nothing is shown; Show returns MessageBoxResult.None immediately.

C#:

```csharp
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)
```

Python:

```python
MessageBox.Show(messageBoxText: str, caption: str, button: MessageBoxButton, icon: MessageBoxImage, defaultResult: MessageBoxResult) -> MessageBoxResult
```

### Parameters

- `messageBoxText` (`string`, Python `str`): The text that will be displayed on MessageBox
- `caption` (`string`, Python `str`): The caption that will be displayed on MessageBox tile bar
- `button` (`MessageBoxButton`, Python `MessageBoxButton`): The button that will be displayed on MessageBox
- `icon` (`MessageBoxImage`, Python `MessageBoxImage`): The icon that will be displayed on MessageBox
- `defaultResult` (`MessageBoxResult`, Python `MessageBoxResult`): The MessageBox default result

### Returns

`MessageBoxResult` — MessageBoxResult

### Examples

C#:

```csharp
var result = MessageBox.Show("Stop the cBot?", "Confirm", MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.No);
if (result == MessageBoxResult.Yes)
    Stop();
```

Python:

```python
result = MessageBox.Show("Stop the cBot?", "Confirm", MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.No)
if result == MessageBoxResult.Yes:
    api.Stop()
```

## Show(Window owner, string messageBoxText)

Shows a MessageBox with text that is a child of another window

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

- CLI: Nothing is shown; Show returns MessageBoxResult.None immediately.
- Cloud: Nothing is shown; Show returns MessageBoxResult.None immediately.

C#:

```csharp
public static MessageBoxResult Show(Window owner, string messageBoxText)
```

Python:

```python
MessageBox.Show(owner: Window, messageBoxText: str) -> MessageBoxResult
```

### Parameters

- `owner` (`Window`, Python `Window`): The window that owns the MessageBox
- `messageBoxText` (`string`, Python `str`): The text that will be displayed on MessageBox

### Returns

`MessageBoxResult` — MessageBoxResult

### Examples

C#:

```csharp
var window = new Window { Title = "Settings", Width = 300, Height = 200 };
window.Show();
MessageBox.Show(window, "Settings saved");
```

Python:

```python
window = Window()
window.Title = "Settings"
window.Show()
MessageBox.Show(window, "Settings saved")
```

## Show(Window owner, string messageBoxText, string caption)

Shows a MessageBox with text, and caption / title that is a child of another window

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

- CLI: Nothing is shown; Show returns MessageBoxResult.None immediately.
- Cloud: Nothing is shown; Show returns MessageBoxResult.None immediately.

C#:

```csharp
public static MessageBoxResult Show(Window owner, string messageBoxText, string caption)
```

Python:

```python
MessageBox.Show(owner: Window, messageBoxText: str, caption: str) -> MessageBoxResult
```

### Parameters

- `owner` (`Window`, Python `Window`): The window that owns the MessageBox
- `messageBoxText` (`string`, Python `str`): The text that will be displayed on MessageBox
- `caption` (`string`, Python `str`): The caption that will be displayed on MessageBox tile bar

### Returns

`MessageBoxResult` — MessageBoxResult

### Examples

C#:

```csharp
var window = new Window { Title = "Orders", Width = 300, Height = 200 };
window.Show();
MessageBox.Show(window, "Pending orders: " + PendingOrders.Count, "Orders");
```

Python:

```python
window = Window()
window.Title = "Orders"
window.Show()
MessageBox.Show(window, f"Pending orders: {api.PendingOrders.Count}", "Orders")
```

## Show(Window owner, string messageBoxText, string caption, MessageBoxButton button)

Shows a MessageBox with text, caption / title, and button that is a child of another window

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

- CLI: Nothing is shown; Show returns MessageBoxResult.None immediately.
- Cloud: Nothing is shown; Show returns MessageBoxResult.None immediately.

C#:

```csharp
public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button)
```

Python:

```python
MessageBox.Show(owner: Window, messageBoxText: str, caption: str, button: MessageBoxButton) -> MessageBoxResult
```

### Parameters

- `owner` (`Window`, Python `Window`): The window that owns the MessageBox
- `messageBoxText` (`string`, Python `str`): The text that will be displayed on MessageBox
- `caption` (`string`, Python `str`): The caption that will be displayed on MessageBox tile bar
- `button` (`MessageBoxButton`, Python `MessageBoxButton`): The button that will be displayed on MessageBox

### Returns

`MessageBoxResult` — MessageBoxResult

### Examples

C#:

```csharp
var window = new Window { Title = "Trade panel", Width = 300, Height = 200 };
window.Show();
var result = MessageBox.Show(window, "Cancel all pending orders?", "Confirm", MessageBoxButton.YesNo);
if (result == MessageBoxResult.Yes)
    foreach (var order in PendingOrders.ToArray())
        CancelPendingOrder(order);
```

Python:

```python
window = Window()
window.Title = "Trade panel"
window.Show()
result = MessageBox.Show(window, "Cancel all pending orders?", "Confirm", MessageBoxButton.YesNo)
if result == MessageBoxResult.Yes:
    for order in list(api.PendingOrders):
        api.CancelPendingOrder(order)
```

## Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon)

Shows a MessageBox with text, caption / title, button, and image icon that is a child of another window

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

- CLI: Nothing is shown; Show returns MessageBoxResult.None immediately.
- Cloud: Nothing is shown; Show returns MessageBoxResult.None immediately.

C#:

```csharp
public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon)
```

Python:

```python
MessageBox.Show(owner: Window, messageBoxText: str, caption: str, button: MessageBoxButton, icon: MessageBoxImage) -> MessageBoxResult
```

### Parameters

- `owner` (`Window`, Python `Window`): The window that owns the MessageBox
- `messageBoxText` (`string`, Python `str`): The text that will be displayed on MessageBox
- `caption` (`string`, Python `str`): The caption that will be displayed on MessageBox tile bar
- `button` (`MessageBoxButton`, Python `MessageBoxButton`): The button that will be displayed on MessageBox
- `icon` (`MessageBoxImage`, Python `MessageBoxImage`): The icon that will be displayed on MessageBox

### Returns

`MessageBoxResult` — MessageBoxResult

### Examples

C#:

```csharp
var window = new Window { Title = "Risk", Width = 300, Height = 200 };
window.Show();
MessageBox.Show(window, "Stop loss is required", "Invalid order", MessageBoxButton.OK, MessageBoxImage.Error);
```

Python:

```python
window = Window()
window.Title = "Risk"
window.Show()
MessageBox.Show(window, "Stop loss is required", "Invalid order", MessageBoxButton.OK, MessageBoxImage.Error)
```

## Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)

Shows a MessageBox with text, caption / title, button, icon, and a default result that is a child of another window

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

- CLI: Nothing is shown; Show returns MessageBoxResult.None immediately.
- Cloud: Nothing is shown; Show returns MessageBoxResult.None immediately.

C#:

```csharp
public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)
```

Python:

```python
MessageBox.Show(owner: Window, messageBoxText: str, caption: str, button: MessageBoxButton, icon: MessageBoxImage, defaultResult: MessageBoxResult) -> MessageBoxResult
```

### Parameters

- `owner` (`Window`, Python `Window`): The window that owns the MessageBox
- `messageBoxText` (`string`, Python `str`): The text that will be displayed on MessageBox
- `caption` (`string`, Python `str`): The caption that will be displayed on MessageBox tile bar
- `button` (`MessageBoxButton`, Python `MessageBoxButton`): The button that will be displayed on MessageBox
- `icon` (`MessageBoxImage`, Python `MessageBoxImage`): The icon that will be displayed on MessageBox
- `defaultResult` (`MessageBoxResult`, Python `MessageBoxResult`): The MessageBox default result

### Returns

`MessageBoxResult` — MessageBoxResult

### Examples

C#:

```csharp
var window = new Window { Title = "Strategy", Width = 300, Height = 200 };
window.Show();
var result = MessageBox.Show(window, "Reverse all positions?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
Print("User selected: {0}", result);
```

Python:

```python
window = Window()
window.Title = "Strategy"
window.Show()
result = MessageBox.Show(window, "Reverse all positions?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No)
api.Print(f"User selected: {result}")
```

