Skip to main content
All docs
V26.1
  • XtraInputBox.Show<T>(String, String, T, XtraInputBox.Buttons) Method

    Displays an input box with the specified settings.

    Namespace: DevExpress.XtraEditors

    Assembly: DevExpress.XtraEditors.v26.1.dll

    Declaration

    public static T? Show<T>(
        string prompt,
        string title,
        T defaultResponse,
        XtraInputBox.Buttons buttons
    )
        where T : struct

    Parameters

    Name Type Description
    prompt String

    The text string displayed above an Input Box editor.

    title String

    The Input Box window caption.

    defaultResponse T

    The initial editor value.

    buttons XtraInputBox.Buttons

    Specifies Input Box buttons.

    Type Parameters

    Name Description
    T

    The type of a value requested from users.

    Returns

    Type Description
    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.

    XtraInputBox.Show("Select a date", "Jump to Date", DateTime.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:

    WinForms Input Box with Default Settings, DevExpress

    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");
    

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

    WinForms Input Box with Custom Settings, DevExpress

    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);
    
    See Also