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)

  • Searchable
  • Title

I managed to display this order:

  • Title
  • Searchable

 

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;
    }
}



Comments are closed on this post.

 
Site Map | Printable View | Design by creative & it consulting | © 2009 - 2012 Florian Morrenth