SupportsPreviewControlAttribute クラス
アセンブリ: System.Design (system.design.dll 内)

<AttributeUsageAttribute(AttributeTargets.Class)> _ Public NotInheritable Class SupportsPreviewControlAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Class)] public sealed class SupportsPreviewControlAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class)] public ref class SupportsPreviewControlAttribute sealed : public Attribute

コントロール デザイナでサポートされているプレビュー コントロールの型を示すには、SupportsPreviewControlAttribute 属性をコントロール デザイナ クラスに適用します。この属性は、関連付けられているコントロールで実際に保持されているインスタンスに影響を与えることなく、デザイン時表示のプレビュー コントロールを変更するために使用します。
通常、ControlDesigner クラスから派生したカスタム デザイナ クラスを宣言するときには、SupportsPreviewControlAttribute を指定します。SupportsPreviewControlAttribute 属性の SupportsPreviewControl プロパティの値によって、基本クラス ControlDesigner の UsePreviewControl メンバと ViewControl メンバの動作が決まります。
デザイナが、関連付けられたコントロールの一時的なコピーを使用してデザイン時の HTML を生成することを示す場合は、SupportsPreviewControl プロパティを true に設定します。一時コントロールへの変更は保持されません。
デザイナで、ViewControl メソッドからコントロール インスタンス (特に Component プロパティ) を返すことを示す場合は、SupportsPreviewControl プロパティを false に設定します。コントロール オブジェクトへの変更は保持されます。
たとえば CalendarDesigner クラスは、SupportsPreviewControlAttribute の値が true に設定されてマークされます。デザイナは、スタイルの自動書式指定タスクでプレビュー コントロールを使用します。これによりユーザーは、カレンダーに適用できるさまざまな自動フォーマット スタイルのプレビューを実行できます。ユーザーが異なる自動フォーマット スタイルをユーザー インターフェイスで選択すると、選択したスタイルのスキームがプレビュー コントロールに適用されます。新しいスタイルをプレビュー コントロールに適用しても、デザイナの Calendar コントロールのインスタンスに適用されたスキームは変更されません。
コントロール デザイナの宣言で SupportsPreviewControlAttribute が指定されていない場合、ControlDesigner の動作は、SupportsPreviewControl を false に指定することに相当します。
![]() |
---|
ControlDesigner クラスから派生したデザイナ クラスは、UsePreviewControl メンバと ViewControl メンバをオーバーライドし、SupportsPreviewControlAttribute 属性を無視できます。ViewControl と UsePreviewControl の必要とされる動作を確認するには、派生したコントロール デザイナ クラスのリファレンス ドキュメントを参照してください。 |
属性の使用方法の概要については、「属性の概要」および「属性を使用したメタデータの拡張」を参照してください。デザイン時の属性の詳細については、「属性とデザイン時サポート」を参照してください。

SupportsPreviewControlAttribute 属性でコントロール デザイナをマークする方法を次のコード例に示します。このコード例では、Label クラスから ASP.NET サーバー コントロールを派生し、カスタム コントロール デザイナの実装に関連付けます。コントロール デザイナ クラスの宣言は、SupportsPreviewControl 属性を true に設定してマークされます。コントロール デザイナは、GetDesignTimeHtml メソッドをオーバーライドし、コントロールのデザイン時の HTML を斜体タグで囲みます。
Imports Microsoft.VisualBasic Imports System 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
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. } }

System.Attribute
System.Web.UI.Design.SupportsPreviewControlAttribute


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SupportsPreviewControlAttribute コンストラクタ
アセンブリ: System.Design (system.design.dll 内)

Dim supportsPreviewControl As Boolean Dim instance As New SupportsPreviewControlAttribute(supportsPreviewControl)

通常、SupportsPreviewControlAttribute クラスのインスタンスを直接作成する必要はありません。SupportsPreviewControlAttribute を、ソース コードのカスタム コントロール デザイナのクラス宣言に適用します。


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SupportsPreviewControlAttribute フィールド
SupportsPreviewControlAttribute プロパティ

名前 | 説明 | |
---|---|---|
![]() | SupportsPreviewControl | コントロール デザイナでデザイン時に一時的なプレビュー コントロールが必要かどうかを示す値を取得します。 |
![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。 ( Attribute から継承されます。) |

SupportsPreviewControlAttribute メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 オーバーライドされます。 |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。) |
![]() | GetHashCode | オーバーライドされます。 SupportsPreviewControlAttribute クラスのこのインスタンスのハッシュ コードを返します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | IsDefaultAttribute | オーバーライドされます。 SupportsPreviewControlAttribute クラスの現在のインスタンスがプレビュー属性の既定値に設定されるかどうかを示します。 |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

SupportsPreviewControlAttribute メンバ
コントロール デザイナでデザイン時にコントロールのプレビュー インスタンスが必要かどうかを示します。このクラスは継承できません。
SupportsPreviewControlAttribute データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | SupportsPreviewControlAttribute | SupportsPreviewControlAttribute クラスの新しいインスタンスを初期化して、SupportsPreviewControl プロパティの初期値を設定します。 |


名前 | 説明 | |
---|---|---|
![]() | SupportsPreviewControl | コントロール デザイナでデザイン時に一時的なプレビュー コントロールが必要かどうかを示す値を取得します。 |
![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。(Attribute から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 オーバーライドされます。 |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。) |
![]() | GetHashCode | オーバーライドされます。 SupportsPreviewControlAttribute クラスのこのインスタンスのハッシュ コードを返します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | IsDefaultAttribute | オーバーライドされます。 SupportsPreviewControlAttribute クラスの現在のインスタンスがプレビュー属性の既定値に設定されるかどうかを示します。 |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

- SupportsPreviewControlAttributeのページへのリンク