Adding a drop down list (combo) to the custom property pane on a Sharepoint Web Part.
How to add a drop down list to the property pane
Secondly, let's make use of an enum structure which contains company names (as displayed below).
///<summary>
/// Holds the company names
///</summary>
publicenum CompanyName : int
{
TaxOffice = 0, //This will display customers as Tax Office Customers
PostOffice = 1, //This will display customers as Post Office Customers
Bank = 2, //This will display customers as Bank Customers
Telephone = 3 //This will display customers as Telephone Customers
}
Figure 10: Enum class that hold the company names
I expose this enum class as a Web Part custom property as display below,
///<summary>
/// This property will determine the name of the company.
/// The names of the companies are stored in an enum collection.
/// This will be available in a drop down list.
///</summary>
[Browsable(true),//Display the property in property pane
Category("Customer Details"),//Create a Customer Details category in
property pane
DefaultValue(CompanyName.Bank),//Assign a default value
WebPartStorage(Storage.Personal),//Make available in both personal and
shared mode
FriendlyName("Company name"),//The caption display in property pane
Description("Select the office")]//The tool tip
public CompanyName DisplayCompanyName
{
get
{
return m_enmSelectedCompany;
}
set
{
m_enmSelectedCompany = value;
}
}
Figure 11: Custom property with an enum class
This custom property will display in property pane as below
0 Comments:
Post a Comment
<< Home