Export (0) Print
Expand All

FileDialog.Title Property

Gets or sets the file dialog box title.

[Visual Basic]
Public Property Title As String
[C#]
public string Title {get; set;}
[C++]
public: __property String* get_Title();
public: __property void set_Title(String*);
[JScript]
public function get Title() : String;
public function set Title(String);

Property Value

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

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

Example

[Visual Basic, C#] The following code example demonstrates initializing an OpenFileDialog object, 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 or Load method. This example assumes the Click event of the Button control is connected to the event handling method 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();
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

FileDialog Class | FileDialog Members | System.Windows.Forms Namespace

Show:
© 2014 Microsoft