FileDialog.Title Property

Definition

Gets or sets the file dialog box title.

C#
public string Title { get; set; }

Property Value

The file dialog box title. The default value is an empty string ("").

Examples

The following code example demonstrates initializing an OpenFileDialog, setting the Title and Filter properties, and allowing the user to select multiple files by setting the OpenFileDialog.Multiselect property to true. To run this example, paste the following code in a form containing an OpenFileDialog named OpenFileDialog1 and a Button named fileButton. Call the InitializeOpenFileDialog method in the form's constructor or Load method. The example also requires that the Click event of the Button control is connected to the event handler defined in the example.

C#
private void InitializeOpenFileDialog()
{
    this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();

    // Set the file dialog to filter for graphics files.
    this.openFileDialog1.Filter = 
        "Images (*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|" + 
        "All files (*.*)|*.*";

    // Allow the user to select multiple images.
    this.openFileDialog1.Multiselect = true;
    this.openFileDialog1.Title = "My Image Browser";
}

private void fileButton_Click(System.Object sender, System.EventArgs e)
{
    openFileDialog1.ShowDialog();
}

Remarks

The string is placed in the title bar of the dialog box. If the title is an empty string, the system uses a default title, which is either "Save As" or "Open".

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10