Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 自定义属性没有';在自定义控件的“属性”窗口中不显示_C#_Winforms - Fatal编程技术网

C# 自定义属性没有';在自定义控件的“属性”窗口中不显示

C# 自定义属性没有';在自定义控件的“属性”窗口中不显示,c#,winforms,C#,Winforms,我说的是文件->新建->控制库 在表单上删除了ListView,向其添加了一个新的静态类,如下所示: namespace WindowsFormsControlLibrary1 { public static class TestClass { [Category("Appearance")] public static Color InsertionMarkColor { get; set; } } } 但我希望在测试应用程序中使用I

我说的是文件->新建->控制库

在表单上删除了ListView,向其添加了一个新的静态类,如下所示:

namespace WindowsFormsControlLibrary1
{
    public  static class TestClass
    {
        [Category("Appearance")]
        public static Color InsertionMarkColor { get; set; }
    }
}
但我希望在测试应用程序中使用InsertionMarkColor时看到一个名为InsertionMarkColor的属性,但它没有显示在那里。为什么?
注意:如果我直接在库的源代码中复制粘贴InsertionMarkColor,它会显示并工作,但是如果我想像上面的代码一样将其移动到单独的类中,它就不工作了……您认为缺少什么?

这对我来说很有效:

public class MyListView : ListView {

  [Category("Appearance")]
  public Color InsertionMarkColor { get; set; }

}
这对我很有用:

public class MyListView : ListView {

  [Category("Appearance")]
  public Color InsertionMarkColor { get; set; }

}

删除了“静态”一词,但仍不显示:(你说的独立类是什么意思?属性必须是控件的一部分。你从ListView控件继承了吗?删除了“static”一词,仍然没有显示。:(你说的独立类是什么意思?属性必须是控件的一部分。你从ListView控件继承了吗?