天天看点

PropertyGrid控件 分类(Category)及属性(Property)排序

最近在做表单设计器,设计器上的控件都是我们自己封装的,但每个属性类别里的属性是按照属性的拼音排序的,现在想按照propertyindex标识进行排序(propertyindex的后三位是用来标识编辑器的)。

具体实现如下:

propertyindexattribute类:

排序部分:

设置propertygrid控件的属性:

PropertyGrid控件 分类(Category)及属性(Property)排序

用法:

为每个属性添加属性:[propertyindex("103001000")]

比如:

效果:

PropertyGrid控件 分类(Category)及属性(Property)排序

如果使用网络上的sort排序代码(感觉不对,于是没有采用):

效果如下:

PropertyGrid控件 分类(Category)及属性(Property)排序

本文参考:

<a target="_blank" href="http://greatverve.cnblogs.com/archive/2012/02/08/propergrid-order.html">propertygrid排序</a>

<a target="_blank" href="http://www.codeproject.com/articles/6611/ordering-items-in-the-property-grid">ordering items in the property grid</a>

propertygrid类别排序实现,可以参考:

属性控件propertygrid事件:

由于我用的是:

PropertyGrid控件 分类(Category)及属性(Property)排序

所以在反射的时候,用的是:

而非参考文章中的:

PropertyGrid控件 分类(Category)及属性(Property)排序

控件中的使用:

PropertyGrid控件 分类(Category)及属性(Property)排序
PropertyGrid控件 分类(Category)及属性(Property)排序

完成!