DesignerAutoFormat.Apply Method (Control)
.NET Framework (current version)
Applies the associated formatting to the specified control.
Assembly: System.Design (in System.Design.dll)
Parameters
- control
-
Type:
System.Web.UI.Control
A Web server control to apply the formatting to.
The Apply method applies formatting to the specified control based on the Name property. You can apply the styles directly to the control, or set the Style property and then use the MergeStyle method for the control to apply the style changes to the control.
Notes to Inheritors:
When you inherit from the DesignerAutoFormat class, you must override the Apply method.
The following code example illustrates how to use a DesignerAutoFormat object to apply formatting to a Web server control.
// 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: