Live Chat Icon For mobile
Live Chat Icon

How to make properties in your custom data type appear in a particular order in the property browser

Platform: WinForms| Category: Tips

// Your custom data type
public class MySize
    public int Width{get{...}set{...}}
    public int Height{get{...}set{...}}

For example, in the above class (MySize) if you want to your properties ‘Width’ and ‘Height’ to

appear in that order, you should provide this override:

public override bool GetPropertiesSupported(ITypeDescriptorContext context) 
	return true;
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
	System.ComponentModel.PropertyDescriptorCollection propertyDescriptorCollection;
	string[] propNames;
	propertyDescriptorCollection = 
	propNames = (string[])new System.String[2];
	propNames[0] = @'Width';
	propNames[1] = @'Height';
	return propertyDescriptorCollection0.Sort(propNames);
} // end of method GetProperties

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.