DesignerAutoFormat.Style Eigenschaft

Definition

Ruft ein DesignerAutoFormatStyle-Objekt ab, das vom DesignerAutoFormat-Objekt für eine Entwurfszeitvorschau des zugeordneten Steuerelements verwendet wird.Gets a DesignerAutoFormatStyle object that is used by the DesignerAutoFormat object to render a design-time preview of the associated control.

public:
 property System::Web::UI::Design::DesignerAutoFormatStyle ^ Style { System::Web::UI::Design::DesignerAutoFormatStyle ^ get(); };
public System.Web.UI.Design.DesignerAutoFormatStyle Style { get; }
member this.Style : System.Web.UI.Design.DesignerAutoFormatStyle
Public ReadOnly Property Style As DesignerAutoFormatStyle

Eigenschaftswert

DesignerAutoFormatStyle

Ein Objekt, das vom DesignerAutoFormat-Objekt für eine Entwurfszeitvorschau des zugeordneten Steuerelements verwendet wird.An object that is used by the DesignerAutoFormat object to render a design-time preview of the associated control.

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie mithilfe der-Eigenschaft Formatierungen auf ein Webserver Steuerelement angewendet werden Style .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;
        }
    }
}
' Applies styles based on the Name of the AutoFormat
Public Overrides Sub Apply(ByVal inLabel As Control)
    If TypeOf inLabel Is IndentLabel Then
        Dim ctl As IndentLabel = CType(inLabel, IndentLabel)

        ' Apply formatting according to the Name
        If Me.Name.Equals("MyClassic") Then
            ' 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"
        ElseIf Me.Name.Equals("MyBright") Then
            ' For MyBright, apply style elements to the Style object
            Me.Style.ForeColor = Color.Maroon
            Me.Style.BackColor = Color.Yellow
            Me.Style.Font.Size = FontUnit.Medium

            ' Merge the AutoFormat style with the control's style
            ctl.MergeStyle(Me.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
        End If
    End If
End Sub

Hinweise

Obwohl das von der-Eigenschaft zurückgegebene-Objekt schreibgeschützt Style ist, kann jede einzelne darin enthaltene Eigenschaft festgelegt werden.Although the object returned by the Style property is read-only, each individual property that it contains can be set. Beispielsweise können Sie die- ForeColor Eigenschaft oder die- VerticalAlign Eigenschaft des-Objekts festlegen DesignerAutoFormatStyle .For example, you can set the ForeColor or VerticalAlign property of the DesignerAutoFormatStyle object.

Gilt für:

Siehe auch