CodeSmith实用技巧(三):使用FileDialogAttribute
2005-12-27 13:32
721 查看
使用FileDialogAttribute可以设置FileNameEditor中的属性,基本成员如下:
在下面这段模版代码中,我们设置了弹出的对话框的类型为打开文件对话框,标题为“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
后弹出的对话框界面如下:
属性 | 描述 | 默认值 |
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 |
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
后弹出的对话框界面如下:
相关文章推荐
- CodeSmith实用技巧(三):使用FileDialogAttribute
- CodeSmith实用技巧(十四):使用Progress对象
- Qt实用技巧:界面切换使用Dialog全屏切换
- CodeSmith实用技巧(六):使用XML 属性
- CodeSmith实用技巧(六):使用XML 属性
- CodeSmith实用技巧(十三):使用CodeTemplateInfo对象
- CodeSmith实用技巧(一):使用StringCollection
- CodeSmith实用技巧(六):使用XML 属性
- CodeSmith实用技巧(十三):使用CodeTemplateInfo对象
- CodeSmith实用技巧(十四):使用Progress对象
- 少见但绝对实用的CodeSmith使用技巧
- CodeSmith实用技巧(一):使用StringCollection
- CodeSmith实用技巧(十五):使用快捷键
- CodeSmith实用技巧(二):使用FileNameEditor
- CodeSmith实用技巧(二):使用FileNameEditor
- CodeSmith实用技巧(四):使用扩展属性
- CodeSmith实用技巧(四):使用扩展属性
- CodeSmith实用技巧(十五):使用快捷键
- OpenFileDialog的使用
- 线程中使用SaveFileDialog不能弹出窗体