• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
鱼要的是海洋,鸟要的是天空,我要的是自由!
平凡的人不平凡的人生
博客园    首页    新随笔    联系   管理    订阅  订阅

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

使用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{
 7      get {return _openFileName;}
 8      set {_openFileName= value;}
 9}

10
11执行
12

后弹出的对话框界面如下:

posted @ 2007-06-15 11:05  伊凡  阅读(343)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3