在PropertyGrid中对多个objets的属性进行排序

编程入门 行业动态 更新时间:2024-10-25 20:20:56
本文介绍了在PropertyGrid中对多个objets的属性进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨专家, 我正在处理的应用程序的核心部分是用户可以选择多个对象并更改其属性值的位置。用户界面的用户界面是 PropertyGrid [ ^ ]。 这些对象存在于继承层中,有些是彼此的兄弟姐妹。有些由可以发布可编辑属性的其他对象组成。这些子对象的UI是使用 DockPanelSuite 以类似TabControl的方式排列的其他PropertyGrids [ ^ ]。 用户应选择多个对象,它们合并为一个网格。因此设置一个值会影响所有选定的对象(不同的值会导致值空间保持为空,就像我们从VS中知道的那样)。 子对象多选对象的数据与等于类型的子对象合并(在应用程序的意义上,不是在System.Type中的类型)。但是根据应用程序中的功能,它们被分成几个网格。 通过实现 ICustomTypeDescriptor [ ^ ]。事实上,它们都继承自TranslatableBase基类。 非数字值也由自定义TypeConverter [ ^ ] s。 这已经太久了,我担心。 现在我的问题:在每个PropertyGrid中,字母排序不起作用。 显示的属性序列不是按字母顺序排列的,也不是与源中定义的属性相同。 排序与属性名称(翻译前)不匹配。 [/编辑] 拥有 PropertySort [ ^ ] property设置为按字母排序 [ ^ ]适用于单个选定对象,但不适用于多个 - 选择。 [/ Edit2] 是否有必须遵守的内容以便排序有效?

Hi experts, the central part of an application I'm working on is where User can select multiple objects and change some of their properties' values. The UI for that is a PropertyGrid[^]. The objects live in an inheritance hirarchy, some being siblings of each other. Some are composed of other objects that can publish editable properties as well. Those sub-objects' UI are other PropertyGrids arranged in a TabControl-like manner using DockPanelSuite[^]. Should User select multiple objects, they are merged into one grid. So setting one value affects all selected objects (and differing values cause the value space to be left empty, just as we all know it from VS). Sub-objects of multi-selected objects get merged with sub-objects of equalling type (in the sense of the application, not type as in System.Type). But they are separated into several grids as per their function within the application suggests. Property names are nicely translated for foreign users by the objects implementing ICustomTypeDescriptor[^]. In fact, they all inherit from a "TranslatableBase" base class. Non-numeric values are also translated by custom TypeConverter[^]s. This has already gotten far too long, I fear. Now my problem: Within each PropertyGrid, the alphabetical sorting doesn't work. The sequence of properties as displayed is not alphabetical, nor the same as properties are defined in source. The sorting doesn't match the property names (before the translation) either. [/Edit] Having the PropertySort[^] property set to Alphabetical[^] works for a single selected object, but not for multi-selection. [/Edit2] Is there something one has to adhere to so that sorting works?

推荐答案

搞定了! 我读过所有PropertyGrid [ ^ ]必须关闭内置排序( NoSort [ ^ ])而是 ICustomTypeDescriptor [ ^ ]的 GetProperties [ ^ ]方法应设计为按所需顺序返回属性。 我忽略了应用的 Sort() [ ^ ]方法不排序 PropertyDescriptorCollection [ ^ ]它被调用,但返回一个已排序的新实例。 只是缺少的任务导致排序不起作用。 我的自定义 IComparer [ ^ ]排序方法甚至没有得到应该在什么时候打电话。现在这样做,所以我假设调用被优化了,因为结果没有被使用。 谢谢大家的所有建议。 Got it! I had read that all of PropertyGrid[^]'s built-in sorting had to be switched off (NoSort[^]) and instead ICustomTypeDescriptor[^]'s GetProperties[^] method should be designed to return the properties in the desired order. What I had overlooked was that the applied Sort()[^] method doesn't sort the PropertyDescriptorCollection[^] that it is called upon, but returns a sorted new instance. Just that missing assignment caused the sorting not to work. And my custom IComparer[^] sorting method didn't even get called when in should have been. It does now so I assume that the call was optimized away because the result was not used anyway. Thank you guys for all your suggestions.

更多推荐

在PropertyGrid中对多个objets的属性进行排序

本文发布于:2023-11-12 12:52:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581545.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   中对   属性   PropertyGrid   objets

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!