代码改变世界

[CODE Smith]属性窗中填写属性时使用选择文件夹路径

2008-02-19 14:21  Jaypei  阅读(430)  评论(0编辑  收藏  举报

在Property窗口中填写属性时可使用系统对话框

// 选择文件夹
[Editor(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))]

同理,也可使用System.Windows.Forms.Design.FileNameEditor。

或者使用CodeSmith.CustomProperties下的:

[Editor(typeof(FileNameEditor), 
    
typeof(System.Drawing.Design.UITypeEditor)),
    FileDialogAttribute(FileDialogType.Open,Filter
="Text File(*.txt)|*.txt|All file(*.*)|*.*",Title="Select input file")]


或者:

<%@ Property Name="FileName" Type="System.String" Default="C:" Optional="False" Category="Custom" Description="Test the CodeSmith.CustomProperty.FileNameEditor" Editor="CodeSmith.CustomProperties.FileNameEditor" EditorBase="System.Drawing.Design.UITypeEditor" %>