“属性”网格中的文件的可编辑FullPath属性 - Visual Studio 2008

时间:2009-11-06 10:22:47

标签: visual-studio propertygrid extensibility

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

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

1 个答案:

答案 0 :(得分: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; }
    }
    
  4. mgznet.com/EditFullPathProperty.aspx