FileDialog.Title 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置文件对话框标题。
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设置 Title 和 Filter 属性,以及允许用户通过将属性设置为 OpenFileDialog.Multiselect true 来选择多个文件。 若要运行此示例,请将以下代码粘贴到包含 OpenFileDialog 命名 OpenFileDialog1
和 Button 命名 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
注解
字符串放置在对话框的标题栏中。 如果标题为空字符串,则系统使用默认标题,即“另存为”或“打开”。