SharePoint Explored

Just another weblog

How to order Web Part properties

I was wondering if there is a way to order the web part properties with the web part has no custom ToolPart associated with it. There is a simple solution for this: just override the GetToolParts() method of the web part and add the tool parts in the desired order. There are some default ToolPart objects we have to add here.

  • WebPartToolPart is responsible for rendering the default properties in the categories, Appearance, Layout and Advanced
  • CustomPropertyToolPart is responsible for adding the browsable properties defined within the web part

Here is the code which does this:

override ToolPart[] GetToolParts()

ToolPart[] toolparts = new ToolPart[2];
WebPartToolPart defaultToolPart = new WebPartToolPart();
CustomPropertyToolPart browsableProperties = new CustomPropertyToolPart();

toolparts[0] = browsableProperties;
toolparts[1] = defaultToolPart;

return toolparts;


February 2, 2010 Posted by | SharePoint Hack | Leave a comment