For example, if you have a custom type:
public class CustomSize
{
public int Width { get { /*...*/ } set { /*...*/ } }
public int Height { get { /*...*/ } set { /*...*/ } }
}
And you want to the Width and Height properties to appear in that order, then provide this override:
public override bool GetPropertiesSupported( ITypeDescriptorContext context )
{ return true; }
public override PropertyDescriptorCollection GetProperties(
ITypeDescriptorContext context, object value, Attribute[] attributes )
{
string[] propNames = new string[] { "Width", "Height" };
PropertyDescriptorCollection pdc =
TypeDescriptor.GetProperties( typeof( System.Drawing.Size ), attributes );
return pdc.Sort( propNames );
}
Contributed from George Shepherd's Windows Forms FAQ