I am using the Microsoft PropertyGrid and I have 2 Categories with 6 Properties:
Category "B开发者_如何学C"
"test1"
"test2"
"test3"
"yoman"
Category "Z"
"test4"
"test5"
What must I do that "yoman" comes at first item in Category "B" ?
You can use a TypeConverter attribute on the class and a Custom Attribute on each Property to Control the display order of Properties in a PropertyGrid. The classes are small and the attributes are straightforward. The code and running example are available in a Code Project article by Paul Tingey (http://www.codeproject.com/Articles/6611/Ordering-Items-in-the-Property-Grid).
Showing properties in the exact order you want while still showing Categories is not easy.
(If you would not care about seeing the categories you could just use PropertyGrid.PropertySort=NoSort
to get your properties in the order as they appear in your code but without showing categories).
This article gives some kind of hack to specify the order while showing categories:
http://www.codeproject.com/KB/tabs/PropertyGridValidation.aspx
精彩评论