Search code examples
c#asp.netintellisenseweb-controlssystem.componentmodel

Recreating "Font" Property Behavior


Controls that inherit off of System.Web.UI.WebControls.WebControl have a property called Font. The type is System.Web.Ui.WebControls.FontInfo.

When working with these controls in the designer, it breaks out the Font property into multiple properties like Font-Bold, Font-Italic, etc. When working with these same WebControls in the codebehind, there's only a Font property (no Font-Bold, Font-Italic, etc).

How can this behavior be manually recreated when creating WebControls? Specifically, what combination of System.ComponentModel attributes can show/hide these properties in Intellisense?


Solution

  • The property that you'd like to expand (Font in this case) should have attribute System.ComponentModel.DesignerSerializationVisibility set to System.ComponentModel.DesignerSerializationVisibility.Content. This is detailed in the following link

    System.ComponentModel.DesignerSerializationVisibility