您的位置:首页 > 其它

CodeSmith实用技巧(三):使用FileDialogAttribute

2005-12-27 13:32 721 查看
使用FileDialogAttribute可以设置FileNameEditor中的属性,基本成员如下:
属性

描述

默认值

FileDialogType

Save or Open

FileDialogType.Save

Filter

Filter string for file extensions

All Files (*.*)|*.*

Title

Dialog box title

Select propertyname

DefaultExtension

Default file extensions

None

CheckFileExists

True to only allow selecting existing files

False

CheckPathExists

True to only allow using existing paths

False

在下面这段模版代码中,我们设置了弹出的对话框的类型为打开文件对话框,标题为“Select Input File”。

1private string _openFileName = @"c:\temp\test.txt";
2[Editor(typeof(FileNameEditor), typeof(System.Drawing.Design.UITypeEditor)),
3FileDialogAttribute(FileDialogType.Open, Title="Select Input File"),
4Category("Custom"), Description("User selected file.")]
5public string OpenFileName
6
11执行
12
后弹出的对话框界面如下:


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: