This project has moved. For the latest updates, please go here.

Set CategoryOrderAttribute

Apr 18, 2016 at 2:41 PM
Hello,

i use the propertygrid and i have create some categories dynamic like this:
    private IEnumerable<PropertyDescriptor> _getProperties()
    {
        // Die Eigenschaften des PluginSetting in Attribute für das PropertyGrid umwandeln
        return _properties.Select(pair =>
        {
            var attributes = new List<Attribute>();
            var setting = pair.Value;
            attributes.Add(new DisplayNameAttribute(setting.DisplayName));
            attributes.Add(new CategoryAttribute(setting.Category));
            attributes.Add(new DescriptionAttribute(setting.Description));
            attributes.Add(new PropertyOrderAttribute(setting.Order));
            if (setting.SecurityMode == SettingSecurityMode.Password)
            {
                attributes.Add(new EditorAttribute(typeof(PasswordEditor), typeof(PasswordEditor)));
            }
            if (ReflectionHelper.HasInterface(setting.Value, typeof(IDictionary)))
            {
                attributes.Add(new EditorAttribute(typeof(CheckListBoxEditor), typeof(CheckListBoxEditor)));
            }
            return new DynamicPropertyDescriptor(this, pair.Key, pair.Value.Value.GetType(), attributes.ToArray());
        });
    }
Sorting is now alphabetical -> Sorting of properties inside category works fine. Now i Try to add CategoryOrder like this:
            attributes.Add(new CategoryOrderAttribute(setting.Category,setting.CategoryOrder));
I create new Public int CategoryOrder which is set on Init for each PropertyAttribute like this:

dynamic settings = new SerializableDynamicObject();
        settings.AnwesenheiteVon = new PluginSetting
        {
            DisplayName = "Test1",
            Description = "",
            Category = "MyTest1",
            CategoryOrder = 0,
            Value = 0,
            Order = 0,
        };
        settings.AnwesenheiteBis = new PluginSetting
        {
            DisplayName = "Test2",
            Description = "",
            Category = "MyTest1",
            CategoryOrder = 0,
            Value = 0,
            Order = 1,
        };

        settings.AnwesenheiteVon = new PluginSetting
        {
            DisplayName = "FirstTest1",
            Description = "",
            Category = "FirstTest",
            CategoryOrder = 1,
            Value = 0,
            Order = 0,
        };
        settings.AnwesenheiteBis = new PluginSetting
        {
            DisplayName = "FirstTest2",
            Description = "",
            Category = "FirstTest",
            CategoryOrder = 1,
            Value = 0,
            Order = 1,
        };
I want to get (MyTest1 -> FirstTest) but i get (FirstTest -> MyTest1)

Do you have any Idea to help me with my problem.

Thanks.

Paul