Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 4
FileDialog Class
 Title Property
Collapse All/Expand All Collapse All
.NET Framework Class Library
FileDialog..::.Title Property

Gets or sets the file dialog box title.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
Visual Basic
Public Property Title As String
C#
public string Title { get; set; }
Visual C++
public:
property String^ Title {
    String^ get ();
    void set (String^ value);
}
F#
member Title : string with get, set

Property Value

Type: System..::.String
The file dialog box title. The default value is an empty string ("").

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".

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.

Visual Basic
    Private Sub InitializeOpenFileDialog()
        Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog

        ' Set the file dialog to filter for graphics files.
        Me.OpenFileDialog1.Filter = _
        "Images (*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*"

        ' Allow the user to select multiple images.
        Me.OpenFileDialog1.Multiselect = True
        Me.OpenFileDialog1.Title = "My Image Browser"
    End Sub

    Private Sub fileButton_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles FileButton.Click
        OpenFileDialog1.ShowDialog()
    End Sub

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();
    }

Visual C++
void InitializeOpenFileDialog()
{
   this->OpenFileDialog1 = gcnew 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";
}

void fileButton_Click( System::Object^ sender, System::EventArgs^ e )
{
   OpenFileDialog1->ShowDialog();
}
Metadata
setting the Title and Filter properties, and allowing the user
to select multiple files by setting the 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 

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker