SupportsPreviewControlAttribute SupportsPreviewControlAttribute SupportsPreviewControlAttribute SupportsPreviewControlAttribute Class

Definición

Indica si un diseñador de controles requiere una instancia de vista preliminar del control en tiempo de diseño.Indicates whether a control designer requires a preview instance of the control at design time. Esta clase no puede heredarse.This class cannot be inherited.

public ref class SupportsPreviewControlAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class SupportsPreviewControlAttribute : Attribute
type SupportsPreviewControlAttribute = class
    inherit Attribute
Public NotInheritable Class SupportsPreviewControlAttribute
Inherits Attribute
Herencia
SupportsPreviewControlAttributeSupportsPreviewControlAttributeSupportsPreviewControlAttributeSupportsPreviewControlAttribute
Atributos

Ejemplos

En el ejemplo de código siguiente se muestra cómo marcar un diseñador de SupportsPreviewControlAttribute controles con el atributo.The following code example demonstrates how to mark a control designer with the SupportsPreviewControlAttribute attribute. En el ejemplo de código se deriva un control de servidor Label ASP.net de la clase y se asocia el control de servidor ASP.net a una implementación personalizada del diseñador de controles.The code example derives an ASP.NET server control from the Label class and associates the ASP.NET server control with a custom control designer implementation. La declaración de clase del diseñador de controles se SupportsPreviewControl marca con el trueatributo establecido en.The control designer class declaration is marked with the SupportsPreviewControl attribute set to true. El diseñador de controles invalida el GetDesignTimeHtml método y agrega el código HTML en tiempo de diseño para el control en las etiquetas en cursiva.The control designer overrides the GetDesignTimeHtml method and encloses the design-time HTML for the control in italic tags.

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

Comentarios

Aplique el SupportsPreviewControlAttribute atributo a una clase de diseñador de controles para indicar el tipo de control de vista previa que es compatible con el diseñador de controles.Apply the SupportsPreviewControlAttribute attribute to a control designer class to indicate the type of preview control that is supported by the control designer. Utilice este atributo para cambiar un control de vista previa para la representación en tiempo de diseño sin afectar a la instancia real conservada del control asociado.Use this attribute to change a preview control for design-time rendering without affecting the actual persisted instance of the associated control.

Normalmente, se especifica SupportsPreviewControlAttribute al declarar una clase de diseñador personalizada que se deriva de la ControlDesigner clase.Typically, you specify the SupportsPreviewControlAttribute when declaring a custom designer class that is derived from the ControlDesigner class. El valor de la SupportsPreviewControl propiedad para el SupportsPreviewControlAttribute atributo determina el comportamiento de los UsePreviewControl miembros ViewControl y de la clase ControlDesigner base.The value of the SupportsPreviewControl property for the SupportsPreviewControlAttribute attribute determines the behavior for the UsePreviewControl and ViewControl members in the base ControlDesigner class.

Establezca la SupportsPreviewControl propiedad en true para indicar que el diseñador utiliza una copia temporal del control asociado para generar el HTML en tiempo de diseño.Set the SupportsPreviewControl property to true to indicate that the designer uses a temporary copy of the associated control to generate the design-time HTML. Los cambios en el control temporal no se conservan.Changes to the temporary control are not persisted.

Establezca la SupportsPreviewControl propiedad en false para indicar que el diseñador devuelve la instancia del control, específicamente Component ViewControl la propiedad, del método.Set the SupportsPreviewControl property to false to indicate that the designer returns the control instance, specifically the Component property, from the ViewControl method. Se conservan los cambios realizados en el objeto de control.Changes to the control object are persisted.

Por ejemplo, la CalendarDesigner clase se marca con la SupportsPreviewControlAttribute establecida en true.For example, the CalendarDesigner class is marked with the SupportsPreviewControlAttribute set to true. El diseñador utiliza el control de vista previa con la tarea de formato de estilo automático, que permite al usuario obtener una vista previa de los distintos stylesthat de autoformato que se pueden aplicar al calendario.The designer uses the preview control with the automatic style formatting task, which allows the user to preview various autoformat stylesthat can be applied to the calendar. Cuando el usuario selecciona distintos estilos de autoformato en la interfaz de usuario, el esquema de estilo seleccionado se aplica al control de vista previa.As the user selects different autoformat styles in the user interface, the selected style scheme is applied to the preview control. Al aplicar un nuevo estilo al control de vista previa, no se cambia el esquema que se aplica a la Calendar instancia del control en el diseñador.Applying a new style to the preview control does not change the scheme that is applied to the instance of the Calendar control in the designer.

Si no ControlDesigner SupportsPreviewControl falsese especifica en la declaración del diseñador de controles, el comportamiento es equivalente a especificar como. SupportsPreviewControlAttributeIf the SupportsPreviewControlAttribute is not specified in the control designer declaration, the ControlDesigner behavior is equivalent to specifying the SupportsPreviewControl as false.

Nota

Las clases de ControlDesigner diseñador derivadas de la clase pueden invalidar los UsePreviewControl miembros y SupportsPreviewControlAttribute ViewControl y omitir el atributo.Designer classes derived from the ControlDesigner class can override the UsePreviewControl and ViewControl members, and ignore the SupportsPreviewControlAttribute attribute. Para determinar el comportamiento esperado para ViewControl y UsePreviewControl, vea la documentación de referencia de la clase del diseñador de controles derivados.To determine the expected behavior for ViewControl and UsePreviewControl, see the reference documentation for the derived control designer class.

Para obtener información general sobre el uso de atributos, vea información general sobre atributos y atributos.For general information about using attributes, see Attributes Overview and Attributes. Para obtener más información sobre los atributos de tiempo de diseño, vea atributos y compatibilidad en tiempo de diseño.For more information about design-time attributes, see Attributes and Design-Time Support.

Constructores

SupportsPreviewControlAttribute(Boolean) SupportsPreviewControlAttribute(Boolean) SupportsPreviewControlAttribute(Boolean) SupportsPreviewControlAttribute(Boolean)

Inicializa una instancia nueva de la clase SupportsPreviewControlAttribute y establece el valor inicial de la propiedad SupportsPreviewControl.Initializes a new instance of the SupportsPreviewControlAttribute class and sets the initial value of the SupportsPreviewControl property.

Campos

Default Default Default Default

Obtiene una instancia de la clase SupportsPreviewControlAttribute establecida en el valor de vista preliminar predeterminado.Gets an instance of the SupportsPreviewControlAttribute class that is set to the default preview value. Este campo es de solo lectura.This field is read-only.

Propiedades

SupportsPreviewControl SupportsPreviewControl SupportsPreviewControl SupportsPreviewControl

Obtiene un valor que indica si el diseñador de controles requiere un control de vista preliminar temporal en tiempo de diseño.Gets a value indicating whether the control designer requires a temporary preview control at design time.

TypeId TypeId TypeId TypeId

Cuando se implementa en una clase derivada, obtiene un identificador único para este Attribute.When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)

Métodos

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina si el objeto especificado representa la misma configuración de atributo de vista preliminar que la instancia actual de la clase SupportsPreviewControlAttribute.Determines whether the specified object represents the same preview attribute setting as the current instance of the SupportsPreviewControlAttribute class.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Devuelve el código hash de esta instancia de la clase SupportsPreviewControlAttribute.Returns the hash code for this instance of the SupportsPreviewControlAttribute class.

GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute()

Indica si la instancia actual de la clase SupportsPreviewControlAttribute está establecida en el valor del atributo de la vista preliminar predeterminado.Indicates whether the current instance of the SupportsPreviewControlAttribute class is set to the default preview attribute value.

Match(Object) Match(Object) Match(Object) Match(Object)

Cuando se invalida en una clase derivada, devuelve un valor que indica si esta instancia es igual a un objeto especificado.When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Inherited from Object)

Implementaciones de interfaz explícitas

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

Asigna un conjunto de nombres a un conjunto correspondiente de identificadores de envío.Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Obtiene la información de tipos de un objeto, que puede utilizarse para obtener la información de tipos de una interfaz.Retrieves the type information for an object, which can be used to get the type information for an interface.

(Inherited from Attribute)
_Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32)

Recupera el número de interfaces de información de tipo que proporciona un objeto (0 ó 1).Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Proporciona acceso a las propiedades y los métodos expuestos por un objeto.Provides access to properties and methods exposed by an object.

(Inherited from Attribute)

Se aplica a

Consulte también: