R – How to you make your custom property of a webpart in SharePoint 2007, sort to the top of the property pane

sharepointsharepoint-2007web-parts

In SharePoint 2007, is it possible to programmatically sort the custom property you created to the top of the property pane? So when someone edits your webpart it would show at the top, rather than at the bottom by default, so that the user wouldn't have to scroll to the bottom?

Here's my code, for reference:

    private string _strMainFolder = "Reports";

    [WebBrowsable(true)]
    [WebDisplayName("Reports SharePoint List Name")]
    [SPWebCategoryName("Report WebPart Configuration")]
    [WebPartStorage(Storage.Shared)]
    [WebDescription("Enter the SharePoint List's name that you want to use.")]
    [Personalizable(PersonalizationScope.Shared)]
    public string strMainFolder
    {
        get { return _strMainFolder; }
        set { _strMainFolder = value; }
    }

Best Answer

When you add your CustomPropertyToolPart to the array, give it a lower (0) index than the WebPartToolPart. It should render in the order the items are added to the array.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.webpart.gettoolparts.aspx

Related Topic