0

我的 VS 2008 解决方案中有一个项目,其中包含文件项。每个项目在属性网格中都有一个名为“FullPath”的标准只读属性。

使属性网格的 FullPath 属性可编辑的最简单方法是什么?

4

1 回答 1

1
  1. 添加对 System.Design 的引用

  2. 创建类

    public class DllFileNameEditor :
    System.Windows.Forms.Design.FileNameEditor   {         protected override void InitializeDialog(OpenFileDialog openFileDialog)
    {
        base.InitializeDialog(openFileDialog);
        openFileDialog.Filter = "Class Library Files (*.dll) |*.dll|All (*.*) |*.*";
        openFileDialog.Title = "Select Class Library File";
    } }
    
  3. 修改属性

    [Category("Identity")]
    [Description("Dll Location")]
    [EditorAttribute(typeof(DllFileNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
    public string DllName
    {
        get { return this.GraphDoc.DllName; }
        set { this.GraphDoc.DllName = value; }
    }
    

mgznet.com/EditFullPathProperty.aspx

于 2009-11-09T19:16:49.520 回答