Skip to main content

MessageBox Class

NuGet: GHIElectronics.TinyCLR.UI
Assembly: GHIElectronics.TinyCLR.UI
Namespace: GHIElectronics.TinyCLR.UI.Controls

WinForms-style modal message box. Usage: MessageBox.DefaultFont = myFont; // once at app start var r = MessageBox.Show("Erase all data?", "Confirm", MessageBoxButtons.YesNo); if (r == DialogResult.Yes) { ... } Show() is synchronous: it nests a dispatcher frame so the UI keeps painting and dispatching input while the box is up, and returns when the user picks a button (or Esc cancels). Safe to call from any UI-thread event handler.

public static class MessageBox

Properties

DefaultFont

public static Font DefaultFont { get; set; }

Optional default font. Set this once at startup so callers don't have to pass a Font on every call. Each Show overload that omits a Font uses this value.

Methods

Show(string message, string caption, MessageBoxButtons buttons)

public static DialogResult Show(string message, string caption, MessageBoxButtons buttons)

Shows a modal message box using DefaultFont and returns the button the user picked.

Returns DialogResult

Show(string message, string caption, MessageBoxButtons buttons, Font font)

public static DialogResult Show(string message, string caption, MessageBoxButtons buttons, Font font)

Shows a modal message box with the given font and returns the button the user picked.

Returns DialogResult

Show(UIElement owner, string message, string caption, MessageBoxButtons buttons, Font font)

public static DialogResult Show(UIElement owner, string message, string caption, MessageBoxButtons buttons, Font font)

Shows a modal message box hosted under the given owner and returns the button the user picked.

Returns DialogResult