Back to Devexpress

XtraInputBox.Show<T>(String, String, T) Method

windowsforms-devexpress-dot-xtraeditors-dot-xtrainputbox-dot-show-1-x28-system-dot-string-system-dot-string-0-x29.md

latest5.0 KB
Original Source

XtraInputBox.Show<T>(String, String, T) Method

Displays an input box with the specified title, prompt, and default response. You can also specify the returned value’s type.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public static T? Show<T>(
    string prompt,
    string title,
    T defaultResponse
)
    where T : struct
vb
Public Shared Function Show(Of T As Structure)(
    prompt As String,
    title As String,
    defaultResponse As T
) As T?

Parameters

NameTypeDescription
promptString

The text above the editor.

| | title | String |

The text in the title bar.

| | defaultResponse | T |

The editor’s default value.

|

Type Parameters

NameDescription
T

The returned value’s type.

|

Returns

TypeDescription
Nullable<T>

The value entered by a user, or null if nothing was entered.

|

Remarks

The code below illustrates how to invoke an XtraInputBox with a DateEdit editor.

csharp
XtraInputBox.Show("Select a date", "Jump to Date", DateTime.Now, Buttons.OKCancel);
vb
XtraInputBox.Show("Select a date", "Jump to Date", Date.Now, Buttons.OKCancel)

You can also use XtraInputBoxArgs objects to pass required Input Box settings.

The following code snippet displays a dialog box with default settings:

csharp
using DevExpress.XtraEditors;

// Display an input box with the specified prompt, title, and default response.
XtraInputBox.Show("Enter a new value", "Change Settings", "Default");

// Display an input box with the specified owner, prompt, title, and default response.
XtraInputBox.Show(this, "Enter a new value", "Change Settings", "Default");
vb
Imports DevExpress.XtraEditors

' Display an input box with the specified owner, prompt, title, and default response.
XtraInputBox.Show("Enter a new value", "Change Settings", "Default")

' Display an input box with the specified owner, prompt, title, and default response.
XtraInputBox.Show(Me, "Enter a new value", "Change Settings", "Default")

The following code snippet displays an input box with the specified text, caption, and editor:

csharp
using DevExpress.XtraEditors;

// Create a DateEdit and customize its settings.
DateEdit dateEditor = new DateEdit();

dateEditor.Properties.CalendarView = DevExpress.XtraEditors.Repository.CalendarView.TouchUI;
dateEditor.Properties.Mask.EditMask = "MMMM d, yyyy";

// Initialize a new XtraInputBoxArgs instance with the specified settings.
XtraInputBoxArgs args = new XtraInputBoxArgs()
{
    Caption = "Shipping Options",
    Prompt = "Delivery Date",
    DefaultButtonIndex = 0,
    Editor = dateEditor,
    DefaultResponse = DateTime.Now.Date.AddDays(3) // The date editor's default value
};

// Display the input box and assign the dialog result to a variable.
var result = XtraInputBox.Show(args);
vb
Imports DevExpress.XtraEditors

' Create a DateEdit and customize its settings.
Dim dateEditor As New DateEdit()

dateEditor.Properties.CalendarView = DevExpress.XtraEditors.Repository.CalendarView.TouchUI
dateEditor.Properties.Mask.EditMask = "MMMM d, yyyy"

' Initialize a new XtraInputBoxArgs instance with the specified settings.
Dim args As New XtraInputBoxArgs() With {
    .Caption = "Shipping Options",
    .Prompt = "Delivery Date",
    .DefaultButtonIndex = 0,
    .Editor = dateEditor,
    .DefaultResponse = DateTime.Now.Date.AddDays(3) ' The date editor's default value
}

' Display the input box and assign the dialog result to a variable.
Dim result = XtraInputBox.Show(args)

See Also

XtraInputBox Class

XtraInputBox Members

DevExpress.XtraEditors Namespace