Search Results for

Show / Hide Table of Contents

# Class MessageBox

MessageBox displays a modal message to the user, with a title, a message and a series of options that the user can choose from.

##### Inheritance

System.Object
MessageBox

##### Inherited Members

System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()

###### Namespace: Terminal.Gui

###### Assembly: Terminal.Gui.dll

##### Syntax

    public static class MessageBox

##### Examples

    var n = MessageBox.Query ("Quit Demo", "Are you sure you want to quit this demo?", "Yes", "No");
    if (n == 0)
       quit = true;
    else
       quit = false;

### Methods

#### ErrorQuery(ustring, ustring, ustring[])

Presents an error MessageBox with the specified title and message and a list of buttons to show to the user.

##### Declaration

    public static int ErrorQuery(ustring title, ustring message, params ustring[] buttons)

##### Parameters

Type | Name | Description
--- | --- | ---
NStack.ustring | title | Title for the query.
NStack.ustring | message | Message to display, might contain multiple lines.
NStack.ustring[] | buttons | Array of buttons to add.

##### Returns

Type | Description
--- | ---
System.Int32 | The index of the selected button, or -1 if the user pressed ESC to close the dialog.

##### Remarks

The message box will be vertically and horizontally centered in the container and the size will be automatically determined from the size of the title, message. and buttons.

#### ErrorQuery(ustring, ustring, Int32, ustring[])

Presents an error MessageBox with the specified title and message and a list of buttons to show to the user.

##### Declaration

    public static int ErrorQuery(ustring title, ustring message, int defaultButton = 0, params ustring[] buttons)

##### Parameters

Type | Name | Description
--- | --- | ---
NStack.ustring | title | Title for the query.
NStack.ustring | message | Message to display, might contain multiple lines.
System.Int32 | defaultButton | Index of the default button.
NStack.ustring[] | buttons | Array of buttons to add.

##### Returns

Type | Description
--- | ---
System.Int32 | The index of the selected button, or -1 if the user pressed ESC to close the dialog.

##### Remarks

The message box will be vertically and horizontally centered in the container and the size will be automatically determined from the size of the title, message. and buttons.

#### ErrorQuery(Int32, Int32, ustring, ustring, ustring[])

Presents an error MessageBox with the specified title and message and a list of buttons to show to the user.

##### Declaration

    public static int ErrorQuery(int width, int height, ustring title, ustring message, params ustring[] buttons)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | width | Width for the window.
System.Int32 | height | Height for the window.
NStack.ustring | title | Title for the query.
NStack.ustring | message | Message to display, might contain multiple lines.
NStack.ustring[] | buttons | Array of buttons to add.

##### Returns

Type | Description
--- | ---
System.Int32 | The index of the selected button, or -1 if the user pressed ESC to close the dialog.

##### Remarks

Use ErrorQuery(ustring, ustring, ustring[]) instead; it automatically sizes the MessageBox based on the contents.

#### ErrorQuery(Int32, Int32, ustring, ustring, Int32, ustring[])

Presents an error MessageBox with the specified title and message and a list of buttons to show to the user.

##### Declaration

    public static int ErrorQuery(int width, int height, ustring title, ustring message, int defaultButton = 0, params ustring[] buttons)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | width | Width for the window.
System.Int32 | height | Height for the window.
NStack.ustring | title | Title for the query.
NStack.ustring | message | Message to display, might contain multiple lines.
System.Int32 | defaultButton | Index of the default button.
NStack.ustring[] | buttons | Array of buttons to add.

##### Returns

Type | Description
--- | ---
System.Int32 | The index of the selected button, or -1 if the user pressed ESC to close the dialog.

##### Remarks

Use ErrorQuery(ustring, ustring, ustring[]) instead; it automatically sizes the MessageBox based on the contents.

#### Query(ustring, ustring, ustring[])

Presents an error MessageBox with the specified title and message and a list of buttons to show to the user.

##### Declaration

    public static int Query(ustring title, ustring message, params ustring[] buttons)

##### Parameters

Type | Name | Description
--- | --- | ---
NStack.ustring | title | Title for the query.
NStack.ustring | message | Message to display, might contain multiple lines.
NStack.ustring[] | buttons | Array of buttons to add.

##### Returns

Type | Description
--- | ---
System.Int32 | The index of the selected button, or -1 if the user pressed ESC to close the dialog.

##### Remarks

The message box will be vertically and horizontally centered in the container and the size will be automatically determined from the size of the message and buttons.

#### Query(ustring, ustring, Int32, ustring[])

Presents an error MessageBox with the specified title and message and a list of buttons to show to the user.

##### Declaration

    public static int Query(ustring title, ustring message, int defaultButton = 0, params ustring[] buttons)

##### Parameters

Type | Name | Description
--- | --- | ---
NStack.ustring | title | Title for the query.
NStack.ustring | message | Message to display, might contain multiple lines.
System.Int32 | defaultButton | Index of the default button.
NStack.ustring[] | buttons | Array of buttons to add.

##### Returns

Type | Description
--- | ---
System.Int32 | The index of the selected button, or -1 if the user pressed ESC to close the dialog.

##### Remarks

The message box will be vertically and horizontally centered in the container and the size will be automatically determined from the size of the message and buttons.

#### Query(Int32, Int32, ustring, ustring, ustring[])

Presents a normal MessageBox with the specified title and message and a list of buttons to show to the user.

##### Declaration

    public static int Query(int width, int height, ustring title, ustring message, params ustring[] buttons)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | width | Width for the window.
System.Int32 | height | Height for the window.
NStack.ustring | title | Title for the query.
NStack.ustring | message | Message to display, might contain multiple lines.
NStack.ustring[] | buttons | Array of buttons to add.

##### Returns

Type | Description
--- | ---
System.Int32 | The index of the selected button, or -1 if the user pressed ESC to close the dialog.

##### Remarks

Use Query(ustring, ustring, ustring[]) instead; it automatically sizes the MessageBox based on the contents.

#### Query(Int32, Int32, ustring, ustring, Int32, ustring[])

Presents a normal MessageBox with the specified title and message and a list of buttons to show to the user.

##### Declaration

    public static int Query(int width, int height, ustring title, ustring message, int defaultButton = 0, params ustring[] buttons)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | width | Width for the window.
System.Int32 | height | Height for the window.
NStack.ustring | title | Title for the query.
NStack.ustring | message | Message to display, might contain multiple lines.
System.Int32 | defaultButton | Index of the default button.
NStack.ustring[] | buttons | Array of buttons to add.

##### Returns

Type | Description
--- | ---
System.Int32 | The index of the selected button, or -1 if the user pressed ESC to close the dialog.

##### Remarks

Use Query(ustring, ustring, ustring[]) instead; it automatically sizes the MessageBox based on the contents.