DesignerAutoFormat.Apply(Control) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 컨트롤에 연결된 서식을 적용합니다.
public:
abstract void Apply(System::Web::UI::Control ^ control);
public abstract void Apply(System.Web.UI.Control control);
abstract member Apply : System.Web.UI.Control -> unit
Public MustOverride Sub Apply (control As Control)
매개 변수
- control
- Control
서식을 적용할 웹 서버 컨트롤입니다.
예제
다음 코드 예제에서는 웹 서버 컨트롤에 서식을 DesignerAutoFormat 적용 하는 개체를 사용 하는 방법을 보여 줍니다.
// 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
설명
이 메서드는 Apply 속성에 따라 지정된 컨트롤에 서식을 Name 적용합니다. 스타일을 컨트롤에 직접 적용하거나 속성을 설정한 Style 다음 컨트롤에 대한 메서드를 사용하여 MergeStyle 스타일 변경 내용을 컨트롤에 적용할 수 있습니다.
구현자 참고
클래스에서 상속할 때 메서드를 DesignerAutoFormat 재정의 Apply(Control) 해야 합니다.