DesignerAutoFormat.Style Property
.NET Framework (current version)
Gets a DesignerAutoFormatStyle object that is used by the DesignerAutoFormat object to render a design-time preview of the associated control.
Assembly: System.Design (in System.Design.dll)
Property Value
Type: System.Web.UI.Design.DesignerAutoFormatStyleAn object that is used by the DesignerAutoFormat object to render a design-time preview of the associated control.
Although the object returned by the Style property is read-only, each individual property that it contains can be set. For example, you can set the ForeColor or VerticalAlign property of the DesignerAutoFormatStyle object.
The following code example illustrates how to apply formatting to a Web server control by using the Style property.
// Applies styles based on the Name of the AutoFormat public override void Apply(Control inLabel) { if (inLabel is IndentLabel) { IndentLabel ctl = (IndentLabel)inLabel; // Apply formatting according to the Name if (this.Name == "MyClassic") { // For MyClassic, apply style elements directly to the control ctl.ForeColor = Color.Gray; ctl.BackColor = Color.LightGray; ctl.Font.Size = FontUnit.XSmall; ctl.Font.Name = "Verdana,Geneva,Sans-Serif"; } else if (this.Name == "MyBright") { // For MyBright, apply style elements to the Style property this.Style.ForeColor = Color.Maroon; this.Style.BackColor = Color.Yellow; this.Style.Font.Size = FontUnit.Medium; // Merge the AutoFormat style with the control's style ctl.MergeStyle(this.Style); } else { // For the Default format, apply style elements to the control ctl.ForeColor = Color.Black; ctl.BackColor = Color.Empty; ctl.Font.Size = FontUnit.XSmall; } } }
.NET Framework
Available since 2.0
Available since 2.0
Show: