SupportsPreviewControlAttribute 클래스

정의

디자인 타임에 컨트롤의 미리 보기 인스턴스가 컨트롤 디자이너에 필요한지 여부를 나타냅니다. 이 클래스는 상속될 수 없습니다.

public ref class SupportsPreviewControlAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class SupportsPreviewControlAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type SupportsPreviewControlAttribute = class
    inherit Attribute
Public NotInheritable Class SupportsPreviewControlAttribute
Inherits Attribute
상속
SupportsPreviewControlAttribute
특성

예제

다음 코드 예제에서는 컨트롤 디자이너를 표시 하는 방법에 설명 합니다 SupportsPreviewControlAttribute 특성입니다. 코드 예제는 ASP.NET 서버 컨트롤에서 파생 되는 Label 클래스 및 사용자 지정 컨트롤 디자이너 구현을 사용 하 여 ASP.NET 서버 컨트롤을 연결 합니다. 컨트롤 디자이너 클래스 선언으로 표시 되는 SupportsPreviewControl 특성이 설정 true합니다. 컨트롤 디자이너 재정의 GetDesignTimeHtml 메서드 기울임꼴 태그에서 컨트롤에 대 한 디자인 타임 HTML을 묶습니다.

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.Design.WebControls;
using System.Web.UI.WebControls;
using System.Reflection;

namespace ControlDesignerSamples.CS
{
    // Define a simple designer associated with a 
    // simple text web control.
    
    // Mark the designer with the SupportsPreviewControlAttribute set
    // to true.  This means the base.UsePreviewControl returns true,
    // and base.ViewControl returns a temporary preview copy of the control.
    [SupportsPreviewControl(true)]
    public class SimpleTextControlDesigner : TextControlDesigner
    {		
        // Override the base GetDesignTimeHtml method to display 
        // the design time text in italics.
        public override string GetDesignTimeHtml()
        {
            string html = String.Empty;
 
            try
            {
                // Initialize the return string to the default
                // design time html of the base TextControlDesigner.
                html = base.GetDesignTimeHtml();

                // Get the ViewControl for the associated control.
                Label ctrl = (Label)ViewControl;

                ctrl.Style.Add(HtmlTextWriterStyle.FontStyle, "Italic");
                html = base.GetDesignTimeHtml();
            }
            catch (System.Exception e)
            {
               if (String.IsNullOrEmpty(html))
               {
                   html = GetErrorDesignTimeHtml(e);
               }
            }
            
            return html;
        }
    }

    // Derive a simple Web control from Label to render a text string.
    // Associate this control with the SimpleTextControlDesigner.
    [DesignerAttribute("ControlDesignerSamples.CS.SimpleTextControlDesigner"),
    ToolboxData("<{0}:MyLabelControl Runat=\"Server\"><{0}:MyLabelControl>")]
    public class MyLabelControl : Label
    {
        // Use the Label control implementation, but associate
        // the derived class with the custom control designer.
    }
}
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.Design.WebControls
Imports System.Web.UI.WebControls
Imports System.Reflection

Namespace ControlDesignerSamples.VB

    ' Derive a simple Web control from Label to render a text string.
    ' Associate this control with the SimpleTextControlDesigner.
    <DesignerAttribute("ControlDesignerSamples.CS.SimpleTextControlDesigner"), _
    ToolboxData("<{0}:MyLabelControl Runat=""Server""><{0}:MyLabelControl>")> _
    Public Class MyLabelControl
        Inherits Label

        ' Use the Label control implementation, but associate
        ' the derived class with the custom control designer.
    End Class


    ' Mark the designer with the SupportsPreviewControlAttribute set
    ' to true.  This means the base.UsePreviewControl returns true,
    ' and base.ViewControl returns a temporary preview copy of the control.
    <SupportsPreviewControl(True)> _
    Public Class SimpleTextControlDesigner
        Inherits TextControlDesigner

        ' Override the base GetDesignTimeHtml method to display 
        ' the design time text in italics.
        Public Overrides Function GetDesignTimeHtml() As String
            Dim html As String = String.Empty

            Try
                ' Get the ViewControl for the associated control.
                Dim ctrl As Label = CType(ViewControl, Label)

                ' Set the default text, if necessary
                If ctrl.Text.Length = 0 Then
                    ctrl.Text = "Sample Text"
                End If

                ' Set the style to italic
                ctrl.Style.Add(HtmlTextWriterStyle.FontStyle, "italic")

                ' Let the base class create the HTML markup
                html = MyBase.GetDesignTimeHtml()
            Catch ex As Exception
                If String.IsNullOrEmpty(html) Then
                    ' Display the exception message
                    html = GetErrorDesignTimeHtml(ex)
                End If
            End Try

            Return html
        End Function

    End Class
End Namespace

설명

적용 된 SupportsPreviewControlAttribute 컨트롤 디자이너에서 지원 되는 미리 보기 컨트롤의 유형을 지정 하는 컨트롤 디자이너 클래스에 특성입니다. 연결된 된 컨트롤의 실제 지속형된 인스턴스에 영향을 주지 않고 디자인 타임 렌더링에 대 한 미리 보기 컨트롤을 변경 하려면이 특성을 사용 합니다.

일반적으로 지정 합니다 SupportsPreviewControlAttribute 에서 파생 되는 사용자 지정 디자이너 클래스를 선언 하는 경우는 ControlDesigner 클래스입니다. 값을 SupportsPreviewControl 속성에 대 한를 SupportsPreviewControlAttribute 특성에 대 한 동작을 결정 합니다 UsePreviewControlViewControl 기본의 멤버 ControlDesigner 클래스.

설정 된 SupportsPreviewControl 속성을 true 디자이너는 디자인 타임 HTML을 생성 하는 연결 된 컨트롤의 임시 복사본을 나타냅니다. 임시 컨트롤에 변경 내용이 유지 되지 않습니다.

설정 합니다 SupportsPreviewControl 속성을 false 디자이너 컨트롤 인스턴스, 특히 반환을 나타내기 위해는 Component 속성에서는 ViewControl 메서드. 컨트롤 개체의 변경 내용은 유지 됩니다.

예를 들어 합니다 CalendarDesigner 가 표시 되는 SupportsPreviewControlAttributetrue합니다. 디자이너 미리 보기 컨트롤을 사용 하 여 자동 스타일 서식 지정 작업을 사용 하면 다양 한 서식 stylesthat 미리 보기를 달력에 적용할 수 있습니다. 사용자가 사용자 인터페이스에서 다양 한 서식 스타일을 선택 하는 대로 선택한 스타일 구성표 미리 보기 컨트롤에 적용 됩니다. 인스턴스에 적용 되는 스키마를 변경 되지 않습니다 미리 보기 컨트롤에 새 스타일 적용을 Calendar 디자이너에서 제어 합니다.

경우는 SupportsPreviewControlAttribute 컨트롤 디자이너 선언에 지정 되지 않은 ControlDesigner 동작은 지정 하는 SupportsPreviewControl 으로 false입니다.

참고

디자이너 클래스에서 파생 되는 ControlDesigner 클래스에서 재정의할 수 있습니다를 UsePreviewControlViewControl 멤버를 무시 하 고는 SupportsPreviewControlAttribute 특성입니다. 에 대 한 예상된 동작을 결정 ViewControlUsePreviewControl, 파생된 컨트롤 디자이너 클래스에 대 한 참조 설명서를 참조 하세요.

특성을 사용 하는 방법에 대 한 일반적인 정보를 참조 하세요 특성 개요 하 고 특성합니다. 디자인 타임 특성에 대 한 자세한 내용은 참조 하세요. 특성 및 디자인 타임 지원을합니다.

생성자

SupportsPreviewControlAttribute(Boolean)

SupportsPreviewControlAttribute 클래스의 새 인스턴스를 초기화하고 SupportsPreviewControl 속성의 초기 값을 설정합니다.

필드

Default

기본 미리 보기 값으로 설정된 SupportsPreviewControlAttribute 클래스의 인스턴스를 가져옵니다. 이 필드는 읽기 전용입니다.

속성

SupportsPreviewControl

디자인 타임에 임시 미리 보기 컨트롤이 컨트롤 디자이너에 필요한지 여부를 나타내는 값을 가져옵니다.

TypeId

파생 클래스에서 구현된 경우 이 Attribute에 대한 고유 식별자를 가져옵니다.

(다음에서 상속됨 Attribute)

메서드

Equals(Object)

지정된 개체가 SupportsPreviewControlAttribute 클래스의 현재 인스턴스와 같은 미리 보기 특성 설정을 나타내는지 여부를 확인합니다.

GetHashCode()

SupportsPreviewControlAttribute 클래스의 이 인스턴스에 대한 해시 코드를 반환합니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IsDefaultAttribute()

SupportsPreviewControlAttribute 클래스의 현재 인스턴스가 기본 미리 보기 특성 값으로 설정되어 있는지 여부를 나타냅니다.

Match(Object)

파생 클래스에서 재정의된 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).

(다음에서 상속됨 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다.

(다음에서 상속됨 Attribute)

적용 대상

추가 정보