Hi,
I have a collection of points that I display in the property grid using a custom PointCollection class that implements the ICustomTypeDescriptor interface. This is the same way as the samples browser implements corresponding functionality. The PointCollection class adds the individual points to the properties' list in a standard way as follows, with the source collection index as an input:
public PropertyDescriptorCollection GetProperties(){ var pds = new PropertyDescriptorCollection(null); for (int i = 0; i < this.Count; i++) { pds.Add(new PointCollectionDescriptor(this, i)); } return pds;}
The PointCollectionDescriptor constructor looks more or less like this:
public PointCollectionDescriptor(PointCollection col, int idx) : base("#" + (idx + 1), null){ this.collection = col; ...
}
The output in the property grid is given in the attached image. As we can see from the image, the individual points seem to be sorted by name by the property grid, even though they are added in proper order in the PropertyDescriptorCollection. Item '#10' should be at the bottom of the list, not as item 2.
How can I get the sort order correct?
I have tried to fix this by overriding the PropertyDescriptorCollection class with an implementation that implements the various sorting methods, and tried using this class instead in the code snippet above. However, when I do this the sorting methods are never called by the property grid!
Regards,Leif
Hello and thank you for posting!
I have been looking into your description and the provided code snippets and I am not sure what might go wrong with the custom comparer that you are using. Would it be possible to share the comparer code or a sample application so I can investigate it for you? Thank you in advance.
attached is a sample application that basically do the same as my main application. The 'PropertyOwner' class has a '#define USE_MY_SORT' directive that is used to enable use of a custom PropertyDescriptorCollection, 'NoneSortingPropertyDescriptorCollection', that should do the sorting. When setting breakpoints in this class' various sorting methods I find that they are never called.