Table of Contents

Method Query

Namespace
Terminal.Gui.Views
Assembly
Terminal.Gui.dll

Query(IApplication, int, int, string, string, params string[])

Displays a MessageBox with fixed dimensions.

public static int? Query(IApplication app, int width, int height, string title, string message, params string[] buttons)

Parameters

app IApplication

The application instance. If null, uses TopRunnableView.

width int

Width for the MessageBox.

height int

Height for the MessageBox.

title string

Title for the MessageBox.

message string

Message to display. May contain multiple lines and will be word-wrapped.

buttons string[]

Array of button labels.

Returns

int?

The index of the selected button, or null if the user pressed GetDefaultKey(Command).

Remarks

Consider using Query(IApplication, string, string, params string[]) which automatically sizes the MessageBox. The last button is the default button.

Exceptions

ArgumentNullException

Thrown if app is null.

Query(IApplication, string, string, params string[])

Displays an auto-sized MessageBox.

public static int? Query(IApplication app, string title, string message, params string[] buttons)

Parameters

app IApplication

The application instance. If null, uses TopRunnableView.

title string

Title for the MessageBox.

message string

Message to display. May contain multiple lines and will be word-wrapped.

buttons string[]

Array of button labels.

Returns

int?

The index of the selected button, or null if the user pressed GetDefaultKey(Command).

Remarks

The MessageBox is centered and auto-sized based on title, message, and buttons. The last button is the default button.

Exceptions

ArgumentNullException

Thrown if app is null.

Query(IApplication, string, string, bool, params string[])

Displays an auto-sized MessageBox with word-wrap control.

public static int? Query(IApplication app, string title, string message, bool wrapMessage = true, params string[] buttons)

Parameters

app IApplication

The application instance. If null, uses TopRunnableView.

title string

Title for the MessageBox.

message string

Message to display. May contain multiple lines.

wrapMessage bool

If true, word-wraps the message; otherwise displays as-is with multi-line support.

buttons string[]

Array of button labels.

Returns

int?

The index of the selected button, or null if the user pressed GetDefaultKey(Command).

Remarks

The MessageBox is centered and auto-sized based on title, message, and buttons. The last button is the default button.

Exceptions

ArgumentNullException

Thrown if app is null.