I am overriding my GetProperties() and Sort Methods of an objects PropertyDescriptorCollection in order to sort by index of a collection.
In the ms winforms propertyGrid this is displaying as expected, while in the Telerik radPropertyGrid it is not performing the same as the picture depicts.
Is there a reason this isn't compatible with the Telerik PropertyGrid?
Below is the code for the PropertyDescriptorCollection sort and GetProperties overrides:
The object being displayed in the propertyGrid
The form:
The only difference between the two projects is the propertyGrid
In the ms winforms propertyGrid this is displaying as expected, while in the Telerik radPropertyGrid it is not performing the same as the picture depicts.
Is there a reason this isn't compatible with the Telerik PropertyGrid?
Below is the code for the PropertyDescriptorCollection sort and GetProperties overrides:
class UserDataPropertyDescriptorCollection : PropertyDescriptorCollection{ public UserDataPropertyDescriptorCollection(PropertyDescriptor[] propertyDescriptors) : base(propertyDescriptors) { } public override PropertyDescriptorCollection Sort() { PropertyDescriptorCollection ret = new PropertyDescriptorCollection(null); return this; } public override PropertyDescriptorCollection Sort(string[] names) { return this; } public override PropertyDescriptorCollection Sort(string[] names, System.Collections.IComparer comparer) { return this; } public override PropertyDescriptorCollection Sort(System.Collections.IComparer comparer) { return this; }}public class UserDataExpandableObjectConverter : ExpandableObjectConverter{ public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { PropertyDescriptorCollection d = base.GetProperties(context, value, attributes); List<PropertyDescriptor> props = new List<PropertyDescriptor>(); foreach (PropertyDescriptor f in d) { props.Add(f); } UserDataPropertyDescriptorCollection m = new UserDataPropertyDescriptorCollection(props.ToArray()); return m; }}The object being displayed in the propertyGrid
public class alpha{ private UserDataCollection usd; private string test; public alpha() { usd = new UserDataCollection(); test = "Fun"; } [TypeConverterAttribute(typeof(UserDataExpandableObjectConverter))] [Category("Collection")] public UserDataCollection Collection { get { return usd; } set { usd = value; } } [Category("String")] public string Attr { get { return test; } set { test = value; } }}The form:
public Form1(){ InitializeComponent(); UserDataCollection temp = new UserDataCollection(); alpha obj = new alpha(); //Inner test = new Inner(); for (int i = 0; i < 25; i++) { obj.Collection.Add(""); } radPropertyGrid1.SelectedObject = obj;}The only difference between the two projects is the propertyGrid
