0

I Created Custom WebPart Property for SharePoint Visual WebPart with this code (here - full code)

[WebBrowsable(true),
WebDisplayName("Project ID"), 
Personalizable(PersonalizationScope.Shared),
Category("Project Settings")]
public string projectID { get; set; }

the result is this

enter image description here

but, I want my custom propertis display in first of categories. like this

enter image description here

I know can use custome EditorPart (editorPart - code), but it's Requires me to customize each control...

someone know how do to it

1

You can customize the appearance of your properties in the tool pane by doing the following:

  • Expanding and collapsing specific categories when the pane opens. Use the Expand method of either the WebPartToolPart or CustomPropertyToolpart class to expand selected categories.
  • Hiding base class properties. Use the Hide method of the WebPartToolPart class to hide selected properties.
  • Controlling the order of tool parts within a tool pane. (this what you need !)

To controlling the order of tool parts within a tool pane as you want, you should retrieve the tool pane in the array passed to the GetToolParts method of the WebPart class. as something like this code:

public override Microsoft.SharePoint.WebPartPages.ToolPart[] GetToolParts()
        { 
            //A 3 elements array to hold 3 properties pane in the toolpart
            Microsoft.SharePoint.WebPartPages.ToolPart[] allToolParts = new Microsoft.SharePoint.WebPartPages.ToolPart[3];

                //Toolpart for Default properties for every webpart
                Microsoft.SharePoint.WebPartPages.WebPartToolPart standardToolPart = new Microsoft.SharePoint.WebPartPages.WebPartToolPart();
                //Toolpart for Custom properties for every webpart
                Microsoft.SharePoint.WebPartPages.CustomPropertyToolPart customToolParts = new Microsoft.SharePoint.WebPartPages.CustomPropertyToolPart();
                allToolParts[0] = standardToolPart;
                allToolParts[1] = customToolParts;
                //our custom toolpart
                allToolParts[2] = new CustomToolPart();
                return allToolParts;

        }
  • for GetToolParts method, need to use WebPart of Microsoft.SharePoint.WebPartPages.WebPart. and not System.Web.Ui.WebControls.WebParts.WebPart – WantToDo Aug 17 '16 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.