共用方式為


FileDialog.Title 屬性

定義

取得或設定檔案對話方塊的標題。

public:
 property System::String ^ Title { System::String ^ get(); void set(System::String ^ value); };
public string Title { get; set; }
member this.Title : string with get, set
Public Property Title As String

屬性值

檔案對話方塊的標題。 預設值為空字串 ("")。

範例

下列程式碼範例示範初始化 OpenFileDialog 、設定 TitleFilter 屬性,以及允許使用者將 屬性設定 OpenFileDialog.Multiselect 為 true 來選取多個檔案。 若要執行此範例,請將下列程式碼貼到包含 OpenFileDialog 具名 OpenFileDialog1Button 具名 fileButton 的表單中。 InitializeOpenFileDialog在表單的建構函式或 Load 方法中呼叫 方法。 此範例也需要 Click 控制項的 Button 事件連接到範例中所定義的事件處理常式。

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

備註

字串會放在對話方塊的標題列中。 如果標題是空字串,系統會使用預設標題,也就是「另存新檔」或「開啟」。

適用於