DesignerAutoFormat.Style 속성

정의

DesignerAutoFormatStyle 개체에서 연결된 컨트롤의 디자인 타임 미리 보기를 렌더링하는 데 사용하는 DesignerAutoFormat 개체를 가져옵니다.

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

속성 값

DesignerAutoFormatStyle

연결된 컨트롤의 디자인 타임 미리 보기를 렌더링하기 위해 개체에서 사용하는 DesignerAutoFormat 개체입니다.

예제

다음 코드 예제에 사용 하 여 웹 서버 컨트롤에 서식을 적용 하는 방법을 보여 줍니다는 Style 속성입니다.

// 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

설명

개체에서 반환 된 Style 속성은 읽기 전용, 포함 된 각 개별 속성을 설정할 수 있습니다. 예를 들어, 설정할 수 있습니다 합니다 ForeColor 또는 VerticalAlign 의 속성을 DesignerAutoFormatStyle 개체입니다.

적용 대상

추가 정보