winforms PropertyGrid 中的类别层次结构
我有一些可以分为类别和子类别的属性。当我将它们添加到 PropertyGrid 时,所有子类别都位于根目录中,但我希望子类别成为类别的子类别。
class Settings
{
[Category("SubCategory1")]
public bool Property1 { get; set; }
[Category("SubCategory1")]
public bool Property2 { get; set; }
[Category("SubCategory2")]
public bool Property3 { get; set; }
}
PropertyGrid grid = new PropertyGrid();
grid.SelectedObject = new Settings();
我想让它看起来像
-Category1
-SubCategory1
Property1
Property2
-SubCategory2
Property3
I have some properties that could be divided in categories and sub categories. When I add them to the PropertyGrid all subcategories are in the root, but i want sub categories to be children of categories.
class Settings
{
[Category("SubCategory1")]
public bool Property1 { get; set; }
[Category("SubCategory1")]
public bool Property2 { get; set; }
[Category("SubCategory2")]
public bool Property3 { get; set; }
}
PropertyGrid grid = new PropertyGrid();
grid.SelectedObject = new Settings();
I want to make it look like
-Category1
-SubCategory1
Property1
Property2
-SubCategory2
Property3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决办法。方法是使用 TypeConverter 属性和嵌套类。
...
希望它能帮助别人。
I have found a solution. The approach is to use TypeConverter Attribute and nested classes.
...
Hope it will help someone.