Skip to content

MessageBox.Show

method · MessageBox · cAlgo.API

DesktopCLICloud

Shows a MessageBox with just a text

Environment behaviour

CLI — not supported. Nothing is shown; Show returns MessageBoxResult.None immediately.

Cloud — not supported. Nothing is shown; Show returns MessageBoxResult.None immediately.

Overloads

Signature Description
Show(string messageBoxText) Shows a MessageBox with just a text
Show(string messageBoxText, string caption) Shows a MessageBox with text and caption / title
Show(string messageBoxText, string caption, MessageBoxButton button) Shows a MessageBox with text, caption / title, and button
Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon) Shows a MessageBox with text, caption / title, button, and an image icon
Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult) Shows a MessageBox with text, caption / title, button, icon, and a default result
Show(Window owner, string messageBoxText) Shows a MessageBox with text that is a child of another window
Show(Window owner, string messageBoxText, string caption) Shows a MessageBox with text, and caption / title that is a child of another window
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
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
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

Show(string messageBoxText)

Shows a MessageBox with just a text

public static MessageBoxResult Show(string messageBoxText)
MessageBox.Show(messageBoxText: str) -> MessageBoxResult

Parameters

Name C# type Python type Description
messageBoxText string str The text that will be displayed on MessageBox

Returns MessageBoxResult — MessageBoxResult

Examples

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

Show(string messageBoxText, string caption)

Shows a MessageBox with text and caption / title

public static MessageBoxResult Show(string messageBoxText, string caption)
MessageBox.Show(messageBoxText: str, caption: str) -> MessageBoxResult

Parameters

Name C# type Python type Description
messageBoxText string str The text that will be displayed on MessageBox
caption string str The caption that will be displayed on MessageBox tile bar

Returns MessageBoxResult — MessageBoxResult

Examples

MessageBox.Show("Equity: " + Account.Equity, "Account status");
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

public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button)
MessageBox.Show(messageBoxText: str, caption: str, button: MessageBoxButton) -> MessageBoxResult

Parameters

Name C# type Python type Description
messageBoxText string str The text that will be displayed on MessageBox
caption string str The caption that will be displayed on MessageBox tile bar
button MessageBoxButton MessageBoxButton The button that will be displayed on MessageBox

Returns MessageBoxResult — MessageBoxResult

Examples

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));
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

public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon)
MessageBox.Show(messageBoxText: str, caption: str, button: MessageBoxButton, icon: MessageBoxImage) -> MessageBoxResult

Parameters

Name C# type Python type Description
messageBoxText string str The text that will be displayed on MessageBox
caption string str The caption that will be displayed on MessageBox tile bar
button MessageBoxButton MessageBoxButton The button that will be displayed on MessageBox
icon MessageBoxImage MessageBoxImage The icon that will be displayed on MessageBox

Returns MessageBoxResult — MessageBoxResult

Examples

if (Account.MarginLevel < 200)
    MessageBox.Show("Margin level is " + Account.MarginLevel + "%", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
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

public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)
MessageBox.Show(messageBoxText: str, caption: str, button: MessageBoxButton, icon: MessageBoxImage, defaultResult: MessageBoxResult) -> MessageBoxResult

Parameters

Name C# type Python type Description
messageBoxText string str The text that will be displayed on MessageBox
caption string str The caption that will be displayed on MessageBox tile bar
button MessageBoxButton MessageBoxButton The button that will be displayed on MessageBox
icon MessageBoxImage MessageBoxImage The icon that will be displayed on MessageBox
defaultResult MessageBoxResult MessageBoxResult The MessageBox default result

Returns MessageBoxResult — MessageBoxResult

Examples

var result = MessageBox.Show("Stop the cBot?", "Confirm", MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.No);
if (result == MessageBoxResult.Yes)
    Stop();
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

public static MessageBoxResult Show(Window owner, string messageBoxText)
MessageBox.Show(owner: Window, messageBoxText: str) -> MessageBoxResult

Parameters

Name C# type Python type Description
owner Window Window The window that owns the MessageBox
messageBoxText string str The text that will be displayed on MessageBox

Returns MessageBoxResult — MessageBoxResult

Examples

var window = new Window { Title = "Settings", Width = 300, Height = 200 };
window.Show();
MessageBox.Show(window, "Settings saved");
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

public static MessageBoxResult Show(Window owner, string messageBoxText, string caption)
MessageBox.Show(owner: Window, messageBoxText: str, caption: str) -> MessageBoxResult

Parameters

Name C# type Python type Description
owner Window Window The window that owns the MessageBox
messageBoxText string str The text that will be displayed on MessageBox
caption string str The caption that will be displayed on MessageBox tile bar

Returns MessageBoxResult — MessageBoxResult

Examples

var window = new Window { Title = "Orders", Width = 300, Height = 200 };
window.Show();
MessageBox.Show(window, "Pending orders: " + PendingOrders.Count, "Orders");
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

public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button)
MessageBox.Show(owner: Window, messageBoxText: str, caption: str, button: MessageBoxButton) -> MessageBoxResult

Parameters

Name C# type Python type Description
owner Window Window The window that owns the MessageBox
messageBoxText string str The text that will be displayed on MessageBox
caption string str The caption that will be displayed on MessageBox tile bar
button MessageBoxButton MessageBoxButton The button that will be displayed on MessageBox

Returns MessageBoxResult — MessageBoxResult

Examples

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);
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

public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon)
MessageBox.Show(owner: Window, messageBoxText: str, caption: str, button: MessageBoxButton, icon: MessageBoxImage) -> MessageBoxResult

Parameters

Name C# type Python type Description
owner Window Window The window that owns the MessageBox
messageBoxText string str The text that will be displayed on MessageBox
caption string str The caption that will be displayed on MessageBox tile bar
button MessageBoxButton MessageBoxButton The button that will be displayed on MessageBox
icon MessageBoxImage MessageBoxImage The icon that will be displayed on MessageBox

Returns MessageBoxResult — MessageBoxResult

Examples

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);
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

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

Parameters

Name C# type Python type Description
owner Window Window The window that owns the MessageBox
messageBoxText string str The text that will be displayed on MessageBox
caption string str The caption that will be displayed on MessageBox tile bar
button MessageBoxButton MessageBoxButton The button that will be displayed on MessageBox
icon MessageBoxImage MessageBoxImage The icon that will be displayed on MessageBox
defaultResult MessageBoxResult MessageBoxResult The MessageBox default result

Returns MessageBoxResult — MessageBoxResult

Examples

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);
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}")