Skip to content

SaveFileDialog.ShowDialog

method · SaveFileDialog · cAlgo.API Since 5.1

DesktopCLICloud

Shows a file dialog, with the owner as the main Window

Environment behaviour

CLI — not supported. No dialog is shown. Returns FileDialogResult.None.

Cloud — not supported. No dialog is shown. Returns FileDialogResult.None.

Overloads

Signature Description
ShowDialog() Shows a file dialog, with the owner as the main Window
ShowDialog(Window owner) Shows a file dialog, with the passed owner window.

ShowDialog()

Shows a file dialog, with the owner as the main Window

public FileDialogResult ShowDialog()
saveFileDialog.ShowDialog() -> FileDialogResult

Returns FileDialogResult

Examples

var saveFileDialog = new SaveFileDialog { Filter = "Text files (*.txt)|*.txt" };
var result = saveFileDialog.ShowDialog();
if (result == FileDialogResult.OK)
    saveFileDialog.WriteToFile("Net profit: " + History.Sum(trade => trade.NetProfit));
else
    Print("Dialog result: {0}", result);
saveFileDialog = SaveFileDialog()
saveFileDialog.Filter = "Text files (*.txt)|*.txt"
result = saveFileDialog.ShowDialog()
if result == FileDialogResult.OK:
    saveFileDialog.WriteToFile(f"Net profit: {sum(trade.NetProfit for trade in api.History)}")
else:
    api.Print(f"Dialog result: {result}")

ShowDialog(Window owner)

Shows a file dialog, with the passed owner window.

public FileDialogResult ShowDialog(Window owner)
saveFileDialog.ShowDialog(owner: Window) -> FileDialogResult

Parameters

Name C# type Python type Description
owner Window Window The window that owns the file dialog.

Returns FileDialogResult

Examples

var window = new Window { Title = "Export", Width = 300, Height = 150 };
var exportButton = new Button { Text = "Export" };
exportButton.Click += args =>
{
    var saveFileDialog = new SaveFileDialog { DefaultExt = "txt" };
    if (saveFileDialog.ShowDialog(window) == FileDialogResult.OK)
        saveFileDialog.WriteToFile("Equity: " + Account.Equity);
};
window.Child = exportButton;
window.Show();
window = Window()
window.Title = "Export"
window.Width = 300
window.Height = 150
window.Show()
saveFileDialog = SaveFileDialog()
saveFileDialog.DefaultExt = "txt"
if saveFileDialog.ShowDialog(window) == FileDialogResult.OK:
    saveFileDialog.WriteToFile(f"Equity: {api.Account.Equity}")