SupportsPreviewControlAttribute Sınıf

Tanım

Denetim tasarımcısının tasarım zamanında denetimin önizleme örneğini gerektirip gerektirmediğini gösterir. Bu sınıf devralınamaz.

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
Devralma
SupportsPreviewControlAttribute
Öznitelikler

Örnekler

Aşağıdaki kod örneği, bir denetim tasarımcısını özniteliğiyle nasıl işaretleyebileceğinizi SupportsPreviewControlAttribute gösterir. Kod örneği sınıfından Label bir ASP.NET sunucu denetimi türetir ve ASP.NET sunucu denetimini özel denetim tasarımcısı uygulamasıyla ilişkilendirir. Denetim tasarımcısı sınıf bildirimi, özniteliği olarak SupportsPreviewControl ayarlanmış trueolarak işaretlenir. Denetim tasarımcısı yöntemini geçersiz kılar GetDesignTimeHtml ve denetimin tasarım zamanı HTML'sini italik etiketlere ekler.

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

Açıklamalar

SupportsPreviewControlAttribute Denetim tasarımcısı tarafından desteklenen önizleme denetiminin türünü belirtmek için özniteliğini bir denetim tasarımcısı sınıfına uygulayın. İlişkili denetimin kalıcı olan gerçek örneğini etkilemeden tasarım zamanı işleme için önizleme denetimini değiştirmek için bu özniteliği kullanın.

Genellikle, sınıfından SupportsPreviewControlAttribute türetilen ControlDesigner bir özel tasarımcı sınıfı bildirirken öğesini belirtirsiniz. özniteliğinin özelliğinin SupportsPreviewControl SupportsPreviewControlAttribute değeri, temel ControlDesigner sınıftaki ve ViewControl üyeleri için UsePreviewControl davranışı belirler.

Tasarımcının SupportsPreviewControl tasarım zamanı HTML'sini oluşturmak için ilişkili denetimin geçici bir kopyasını kullandığını belirtmek için özelliğini true olarak ayarlayın. Geçici denetimdeki değişiklikler kalıcı değildir.

tasarımcının SupportsPreviewControl yönteminden ViewControl denetim örneğini, özellikle Component de özelliğini döndürdüğünü belirtmek için özelliğini false olarak ayarlayın. Denetim nesnesinde yapılan değişiklikler kalıcıdır.

Örneğin, CalendarDesigner sınıfı olarak ayarlanmış trueolarak SupportsPreviewControlAttribute işaretlenir. Tasarımcı, kullanıcının takvime uygulanabilecek çeşitli otomatik biçim stillerini önizlemesini sağlayan otomatik stil biçimlendirme göreviyle önizleme denetimini kullanır. Kullanıcı kullanıcı arabiriminde farklı otomatik biçim stilleri seçtiğinde, seçilen stil düzeni önizleme denetimine uygulanır. Önizleme denetimine yeni bir stil uygulanması, tasarımcıdaki denetimin örneğine Calendar uygulanan düzeni değiştirmez.

SupportsPreviewControlAttribute denetim tasarımcısı bildiriminde belirtilmezse, ControlDesigner davranış olarak falsebelirtilmesiyle SupportsPreviewControl eşdeğerdir.

Not

sınıfından ControlDesigner türetilen tasarımcı sınıfları ve ViewControl üyelerini UsePreviewControl geçersiz kılabilir ve özniteliğini SupportsPreviewControlAttribute yoksayabilir. ve UsePreviewControliçin beklenen davranışı belirlemek için ViewControl türetilmiş denetim tasarımcısı sınıfının başvuru belgelerine bakın.

Öznitelikleri kullanma hakkında genel bilgi için bkz . Özniteliklere Genel Bakış ve Öznitelikler. Tasarım zamanı öznitelikleri hakkında daha fazla bilgi için bkz . Öznitelikler ve Design-Time Desteği.

Oluşturucular

SupportsPreviewControlAttribute(Boolean)

sınıfının yeni bir örneğini SupportsPreviewControlAttribute başlatır ve özelliğinin SupportsPreviewControl ilk değerini ayarlar.

Alanlar

Default

Sınıfın SupportsPreviewControlAttribute varsayılan önizleme değerine ayarlanmış bir örneğini alır. Bu alan salt okunur durumdadır.

Özellikler

SupportsPreviewControl

Denetim tasarımcısının tasarım zamanında geçici bir önizleme denetimi gerektirip gerektirmediğini belirten bir değer alır.

TypeId

Türetilmiş bir sınıfta uygulandığında, bu Attributeiçin benzersiz bir tanımlayıcı alır.

(Devralındığı yer: Attribute)

Yöntemler

Equals(Object)

Belirtilen nesnenin sınıfın geçerli örneğiyle SupportsPreviewControlAttribute aynı önizleme özniteliği ayarını temsil edip etmediğini belirler.

GetHashCode()

Sınıfının bu örneği SupportsPreviewControlAttribute için karma kodu döndürür.

GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
IsDefaultAttribute()

Sınıfın geçerli örneğinin SupportsPreviewControlAttribute varsayılan önizleme öznitelik değerine ayarlanıp ayarlanmadığını gösterir.

Match(Object)

Türetilmiş bir sınıfta geçersiz kılındığında, bu örneğin belirtilen bir nesneye eşit olup olmadığını gösteren bir değer döndürür.

(Devralındığı yer: Attribute)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Belirtik Arabirim Kullanımları

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

Bir ad kümesini karşılık gelen bir dağıtma tanımlayıcısı kümesine eşler.

(Devralındığı yer: Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Bir arabirimin tür bilgilerini almak için kullanılabilecek bir nesnenin tür bilgilerini alır.

(Devralındığı yer: Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Bir nesnenin sağladığı tür bilgisi arabirimlerinin sayısını alır (0 ya da 1).

(Devralındığı yer: Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Bir nesne tarafından sunulan özelliklere ve yöntemlere erişim sağlar.

(Devralındığı yer: Attribute)

Şunlara uygulanır

Ayrıca bkz.