如何在PropertyGrid上自定义类别排序? [英] How can I customize category sorting on a PropertyGrid?

查看:52
本文介绍了如何在PropertyGrid上自定义类别排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何自定义 PropertyGrid 中的类别排序?

How can I customize the sorting of categories in a PropertyGrid?

如果我设置以下任何一个...

If I set either of the following...

propertyGrid.PropertySort = PropertySort.Categorized;
propertyGrid.PropertySort = PropertySort.CategorizedAlphabetical;

...然后类别将按字母顺序排列.(字母"似乎适用于每个类别中的属性.)如果我使用 PropertySort.NoSort ,则会丢失分类.

... then the categories will be alphabetized. ("Alphabetical" would seem to apply to the properties within each category.) If I use PropertySort.NoSort, I lose categorization.

我正在用 SelectObject 填充我的 PropertyGrid ,这很简单:

I'm populating my PropertyGrid with SelectObject, which is pretty easy:

this.propertyGrid1.SelectedObject = options;

options 是具有适当修饰属性的类的实例:

options is an instance of a class with suitably decorated properties:

    [CategoryAttribute("Category Title"),
    DisplayName("Property Name"),
    Browsable(true),
    ReadOnly(false),
    BindableAttribute(true),
    DesignOnly(false),
    DescriptionAttribute("...")]
    public bool PropertyName {
        get {
            // ...
        }

        set {
            // ...
            this.OnPropertyChanged("PropertyName");
        }
    }

我在六个类别中有几十个属性.

I have a few dozen properties in half a dozen categories.

在保留 SelectedObject 的易用性的同时,有什么方法可以调整类别的排序顺序?

Is there some way I can adjust the category sort order while preserving my ease of use with SelectedObject?

推荐答案

如果您的意思是希望以特定的(非字母顺序)方式对类别进行排序,那么不会-我认为您无法做到这一点.您可能要尝试 VisualHint -我希望它确实有此功能(因为您可以抓住更多的控制权.

If you mean that you want the categories sorted in a specific (non-alphabetical) way, then no - I don't think you can do that. You might want to try VisualHint - I expect it does have this (since you can seize a lot more control).

这篇关于如何在PropertyGrid上自定义类别排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆