By default, the PropertyGrid control does not display property description for properties that users can edit at run time. However, in some case, you may want to display additional information about the properties being edited. PropertyGrid allows you to show a description for each property, similar to the Description pane in the Visual Studio Properties window. You can make property descriptions visible by setting ShowDescription property of the C1PropertyGrid class to True. This adds a description area at the bottom of the PropertyGrid control, showing description for the property currently focused as shown in the GIF below.
PropertyGrid allows you to add property descriptions programmatically by using the Description property. You can use the following code to add property descriptions:
C# |
Copy Code
|
---|---|
public partial class PropertyDescription: Window { public ClassBinding() { InitializeComponent(); // Create object to browse var customer = new Customerdescription(); // Show customer properties propertyGrid.SelectedObject = customer; propertyGrid.ShowDescription = true; } } public class Customerdescription { [Display(Name = "Customer Name", Description = "Stores the name of customer")] public string Name { get; set; } [Display(Name = "e-Mail address", Description = "Unique email address of the customer")] public string EMail { get; set; } [Display(Name = "Customer Address", Description = "Residence Address of the customer")] public string Address { get; set; } [Display(Name = "Customer Since", Description = "Customer's signup date")] public DateTime CustomerSince { get; set; } [Display(Name = "Point Balance", Description = "Balance of the loyalty points")] public int? PointBalance { get; set; } [Display(Name = "Send Newsletter", Description = "Send news letter to the customer")] public bool SendNewsletter { get; set; } } |