Custom Property order in PropertyGridEditorPart
Tuesday, November 03, 2009 11:34:02 AM
Unfortunately I did not find a clean way to apply a custom order a WebPart's Properties in the PropertyGridEditorPart. Apparently the it is ordering the Elements alphabetical desc by the Property Name. This can be quite ugly when eg. Textboxes for Strings and CheckBoxes for Booleans are mixed and mangled. To apply a custom order you must name the relevant WebBrowsable Properties accordingly. But to maintain a neat readable Layout you can apply the WebDisplayName Attribute.
So although the alphabetical order of the displayed PropertyDescription is different (S before T)
I managed to display this order:
relevant code snippet:
[WebBrowsable(true), Personalizable(PersonalizationScope.Shared), WebDisplayName("Searchable"), DefaultValue(true)]
public bool x_Searchable
{
get
{
return searchable;
}
set
{
searchable = value;
}
}
[WebBrowsable(true), Personalizable(PersonalizationScope.Shared)]
public bool Title
{
get
{
return title;
}
set
{
title= value;
}
}