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

  使用 FileDialogAttribute 可以设置 FileNameEditor 中的属性,基本成员如下:

属性<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

描述

默认值

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”。

 1 None.gif private   string  _openFileName  =   @" c:\temp\test.txt " ;
 2 None.gif[Editor( typeof (FileNameEditor),  typeof (System.Drawing.Design.UITypeEditor)),
 3 None.gifFileDialogAttribute(FileDialogType.Open, Title = " Select Input File " ),
 4 None.gifCategory( " Custom " ), Description( " User selected file. " )]
 5 None.gif public   string  OpenFileName
 6 ExpandedBlockStart.gifContractedBlock.gif dot.gif {
 7ExpandedSubBlockStart.gifContractedSubBlock.gif      get dot.gif{return _openFileName;}
 8ExpandedSubBlockStart.gifContractedSubBlock.gif      set dot.gif{_openFileName= value;}
 9ExpandedBlockEnd.gif}

10 None.gif
11 None.gif执行
12 None.gif

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

<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />PIC055.JPG

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值