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

<AttributeUsageAttribute(AttributeTargets.Method Or AttributeTargets.Property Or AttributeTargets.Field Or AttributeTargets.Event)> _ Public NotInheritable Class DesignerSerializationVisibilityAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Event)] public sealed class DesignerSerializationVisibilityAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Method|AttributeTargets::Property|AttributeTargets::Field|AttributeTargets::Event)] public ref class DesignerSerializationVisibilityAttribute sealed : public Attribute

シリアライザでデザイン モード ドキュメントの永続化状態を設定する場合に、デザイン時に設定されたプロパティの値を永続化するために、コンポーネントの初期化メソッドにコードを追加することがよくあります。他の動作を指示する属性が設定されていなければ、ほとんどの基本的な型に対して、既定でこれが行われます。
DesignerSerializationVisibilityAttribute を使用すると、プロパティの値を Visible として初期化コードで永続化するのか、Hidden として初期化コードで永続化しないのか、または Content として、そのプロパティに代入するオブジェクトのパブリックな、隠ぺいされていない各プロパティに対して初期化コードを生成する必要があるのかを示すことができます。
DesignerSerializationVisibilityAttribute のないメンバは、値が Visible の DesignerSerializationVisibilityAttribute を持つものとして扱われます。Visible としてマークされたプロパティの値は、可能であれば、その型のシリアライザでシリアル化されます。特定の型やプロパティに対してカスタムのシリアル化を指定するには、DesignerSerializerAttribute を使用します。

Content に設定された DesignerSerializationVisibilityAttribute の使用方法を次のコード例に示します。この例では、デザイン時に構成できる、ユーザー コントロールのパブリック プロパティの値を永続化します。この例を使用するには、最初に次のコードをコンパイルして、ユーザー コントロール ライブラリを作成します。次に、新しい Windows アプリケーション プロジェクトで、コンパイルされた .dll ファイルへの参照を追加します。Visual Studio を使用している場合は、ContentSerializationExampleControl が自動的に ツールボックス に追加されます。
ツールボックス からコントロールをフォームにドラッグし、[プロパティ] ウィンドウの一覧に示されている DimensionData オブジェクトのプロパティを設定します。フォームのコードを表示すると、コードが親フォームの InitializeComponent メソッドに追加されています。このコードは、コントロールのプロパティの値を、デザイン モードで設定した値に設定します。
Imports System Imports System.Collections Imports System.ComponentModel Imports System.ComponentModel.Design Imports System.Drawing Imports System.Windows.Forms Namespace DesignerSerializationVisibilityTest _ ' The code for this user control declares a public property of type DimensionData with a DesignerSerializationVisibility ' attribute set to DesignerSerializationVisibility.Content, indicating that the properties of the object should be serialized. ' The public, not hidden properties of the object that are set at design time will be persisted in the initialization code ' for the class object. Content persistence will not work for structs without a custom TypeConverter. Public Class ContentSerializationExampleControl Inherits System.Windows.Forms.UserControl Private components As System.ComponentModel.Container = Nothing <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _ Public ReadOnly Property Dimensions() As DimensionData Get Return New DimensionData(Me) End Get End Property Public Sub New() InitializeComponent() End Sub 'New Protected Overloads Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Dispose Private Sub InitializeComponent() End Sub 'InitializeComponent End Class 'ContentSerializationExampleControl ' This attribute indicates that the public properties of this object should be listed in the property grid. <TypeConverterAttribute(GetType(System.ComponentModel.ExpandableObjectConverter))> _ Public Class DimensionData Private owner As Control ' This class reads and writes the Location and Size properties from the Control which it is initialized to. Friend Sub New(ByVal owner As Control) Me.owner = owner End Sub 'New Public Property Location() As Point Get Return owner.Location End Get Set(ByVal Value As Point) owner.Location = Value End Set End Property Public Property FormSize() As Size Get Return owner.Size End Get Set(ByVal Value As Size) owner.Size = Value End Set End Property End Class 'DimensionData End Namespace 'DesignerSerializationVisibilityTest
using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Drawing; using System.Windows.Forms; namespace DesignerSerializationVisibilityTest { // The code for this user control declares a public property of type DimensionData with a DesignerSerializationVisibility // attribute set to DesignerSerializationVisibility.Content, indicating that the properties of the object should be serialized. // The public, not hidden properties of the object that are set at design time will be persisted in the initialization code // for the class object. Content persistence will not work for structs without a custom TypeConverter. public class ContentSerializationExampleControl : System.Windows.Forms.UserControl { private System.ComponentModel.Container components = null; [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public DimensionData Dimensions { get { return new DimensionData(this); } } public ContentSerializationExampleControl() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if( components != null ) components.Dispose(); } base.Dispose( disposing ); } private void InitializeComponent() { components = new System.ComponentModel.Container(); } } [TypeConverterAttribute(typeof(System.ComponentModel.ExpandableObjectConverter))] // This attribute indicates that the public properties of this object should be listed in the property grid. public class DimensionData { private Control owner; // This class reads and writes the Location and Size properties from the Control which it is initialized to. internal DimensionData(Control owner) { this.owner = owner; } public Point Location { get { return owner.Location; } set { owner.Location = value; } } public Size FormSize { get { return owner.Size; } set { owner.Size = value; } } } }
#using <System.Windows.Forms.dll> #using <System.Drawing.dll> #using <System.dll> using namespace System; using namespace System::Collections; using namespace System::ComponentModel; using namespace System::ComponentModel::Design; using namespace System::Drawing; using namespace System::Windows::Forms; // This attribute indicates that the public properties of this object should be listed in the property grid. [TypeConverterAttribute(System::ComponentModel::ExpandableObjectConverter::typeid)] public ref class DimensionData { private: Control^ owner; internal: // This class reads and writes the Location and Size properties from the Control which it is initialized to. DimensionData( Control^ owner ) { this->owner = owner; } public: property Point Location { Point get() { return owner->Location; } void set( Point value ) { owner->Location = value; } } property Size FormSize { Size get() { return owner->Size; } void set( Size value ) { owner->Size = value; } } }; // The code for this user control declares a public property of type DimensionData with a DesignerSerializationVisibility // attribute set to DesignerSerializationVisibility.Content, indicating that the properties of the object should be serialized. // The public, not hidden properties of the object that are set at design time will be persisted in the initialization code // for the class object. Content persistence will not work for structs without a custom TypeConverter. public ref class ContentSerializationExampleControl: public System::Windows::Forms::UserControl { private: System::ComponentModel::Container^ components; public: property DimensionData^ Dimensions { [DesignerSerializationVisibility(DesignerSerializationVisibility::Content)] DimensionData^ get() { return gcnew DimensionData( this ); } } ContentSerializationExampleControl() { InitializeComponent(); } public: ~ContentSerializationExampleControl() { if ( components != nullptr ) { delete components; } } private: void InitializeComponent() { components = gcnew System::ComponentModel::Container; } };
package DesignerSerializationVisibilityTest; import System.*; import System.Collections.*; import System.ComponentModel.*; import System.ComponentModel.Design.*; import System.Drawing.*; import System.Windows.Forms.*; // The code for this user control declares a public property of type // DimensionData with a DesignerSerializationVisibility attribute set // to DesignerSerializationVisibility.Content, indicating that the properties // of the object should be serialized. // The public, not hidden properties of the object that are set at design // time will be persisted in the initialization code for the class object. // Content persistence will not work for structs without a custom // TypeConverter. public class ContentSerializationExampleControl extends System.Windows.Forms.UserControl { private System.ComponentModel.Container components = null; /** @attribute DesignerSerializationVisibility( DesignerSerializationVisibility.Content) */ /** @property */ public DimensionData get_Dimensions() { return new DimensionData(this); } //get_Dimensions public ContentSerializationExampleControl() { InitializeComponent(); } //ContentSerializationExampleControl protected void Dispose(boolean disposing) { if (disposing) { if (components != null) { components.Dispose(); } } super.Dispose(disposing); } //Dispose private void InitializeComponent() { components = new System.ComponentModel.Container(); } //InitializeComponent } //ContentSerializationExampleControl /** @attribute TypeConverterAttribute(System.ComponentModel. ExpandableObjectConverter.class) */ public class DimensionData { // This attribute indicates that the public properties of this // object should be listed in the property grid. private Control owner; // This class reads and writes the Location and Size properties // from the Control which it is initialized to. DimensionData(Control owner) { this.owner = owner; } //DimensionData /** @property */ public Point get_Location() { return owner.get_Location(); } //get_Location /** @property */ public void set_Location(Point value) { owner.set_Location(value); } //set_Location /** @property */ public Size get_FormSize() { return owner.get_Size(); } //get_FormSize /** @property */ public void set_FormSize(Size value) { owner.set_Size(value); } //set_FormSize } //DimensionData

System.Attribute
System.ComponentModel.DesignerSerializationVisibilityAttribute


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


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

Public Sub New ( _ visibility As DesignerSerializationVisibility _ )
Dim visibility As DesignerSerializationVisibility Dim instance As New DesignerSerializationVisibilityAttribute(visibility)
public DesignerSerializationVisibilityAttribute ( DesignerSerializationVisibility visibility )
public: DesignerSerializationVisibilityAttribute ( DesignerSerializationVisibility visibility )
public DesignerSerializationVisibilityAttribute ( DesignerSerializationVisibility visibility )
public function DesignerSerializationVisibilityAttribute ( visibility : DesignerSerializationVisibility )
- visibility
DesignerSerializationVisibility 値の 1 つ。

デザイナによるコンポーネントのプロパティの保存方法を次のコード例に示します。このコードは、新しい DesignerSerializationVisibilityAttribute を作成し、その値を DesignerSerializationVisibilityAttribute.Content に設定します。
<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _ Public Property _ MyProperty() As Integer Get ' Insert code here. Return 0 End Get Set ' Insert code here. End Set End Property
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public int MyProperty { get { // Insert code here. return(0); } set { // Insert code here. } }

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


DesignerSerializationVisibilityAttribute フィールド

名前 | 説明 | |
---|---|---|
![]() | Content | シリアライザがプロパティ自体ではなくプロパティの内容をシリアル化することを指定します。このフィールドは読み取り専用です。 |
![]() | Default | 既定値 (Visible) を指定します。つまり、ビジュアルなデザイナは既定の規則を使用してプロパティの値を生成します。static フィールドは読み取り専用です。 |
![]() | Hidden | シリアライザがプロパティの値をシリアル化しないことを指定します。static フィールドは読み取り専用です。 |
![]() | Visible | シリアライザによるプロパティの値のシリアル化を許可するように指定します。static フィールドは読み取り専用です。 |

DesignerSerializationVisibilityAttribute プロパティ

名前 | 説明 | |
---|---|---|
![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。 ( Attribute から継承されます。) |
![]() | Visibility | プロパティの値を永続化するかどうかと永続化の方法を決定するときにシリアライザが使用する基本的なシリアル化モードを示す値を取得します。 |

DesignerSerializationVisibilityAttribute メソッド

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

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

DesignerSerializationVisibilityAttribute メンバ
デザイン時にコンポーネントのプロパティをシリアル化するときに使用する永続化の種類を指定します。
DesignerSerializationVisibilityAttribute データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | DesignerSerializationVisibilityAttribute | DesignerSerializationVisibility 値を指定して、DesignerSerializationVisibilityAttribute クラスの新しいインスタンスを初期化します。 |

名前 | 説明 | |
---|---|---|
![]() | Content | シリアライザがプロパティ自体ではなくプロパティの内容をシリアル化することを指定します。このフィールドは読み取り専用です。 |
![]() | Default | 既定値 (Visible) を指定します。つまり、ビジュアルなデザイナは既定の規則を使用してプロパティの値を生成します。static フィールドは読み取り専用です。 |
![]() | Hidden | シリアライザがプロパティの値をシリアル化しないことを指定します。static フィールドは読み取り専用です。 |
![]() | Visible | シリアライザによるプロパティの値のシリアル化を許可するように指定します。static フィールドは読み取り専用です。 |

名前 | 説明 | |
---|---|---|
![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。(Attribute から継承されます。) |
![]() | Visibility | プロパティの値を永続化するかどうかと永続化の方法を決定するときにシリアライザが使用する基本的なシリアル化モードを示す値を取得します。 |

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

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

Weblioに収録されているすべての辞書からDesignerSerializationVisibilityAttributeを検索する場合は、下記のリンクをクリックしてください。

- DesignerSerializationVisibilityAttributeのページへのリンク