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

<AttributeUsageAttribute(AttributeTargets.All)> _ Public Class DescriptionAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets::All)] public ref class DescriptionAttribute : public Attribute

ビジュアル デザイナでは、コンポーネント メンバを参照する場合に、指定した説明を [プロパティ] ウィンドウなどに表示できます。この属性の値にアクセスするには、Description を呼び出します。
詳細については、属性の概要、属性を使用したメタデータの拡張 の各トピックを参照してください。

MyImage プロパティを作成する例を次に示します。このプロパティには、DescriptionAttribute と CategoryAttribute の 2 つの属性があります。
<Description("The image associated with the control"), _ Category("Appearance")> _ Public Property MyImage() As Image Get ' Insert code here. Return image1 End Get Set ' Insert code here. End Set End Property
[Description("The image associated with the control"),Category("Appearance")] public Image MyImage { get { // Insert code here. return image1; } set { // Insert code here. } }
public: property Image^ MyImage { [Description("The image associated with the control"),Category("Appearance")] Image^ get() { // Insert code here. return image1; } void set( Image^ value ) { // Insert code here. } }
/** @attribute Description("The image associated with the control") @attribute Category("Appearance") */ /** @property */ public Image get_MyImage() { // Insert code here. return image1; } //get_MyImage /** @property */ public void set_MyImage(Image value) { // Insert code here. } //set_MyImage
MyImage の説明を取得する例を次に示します。最初に、オブジェクトのすべてのプロパティを保持する PropertyDescriptorCollection を取得します。次に、インデックスを付けて PropertyDescriptorCollection から MyImage を取得します。そして、このプロパティの属性を返し、その属性を属性変数に保存します。
最後に、AttributeCollection から DescriptionAttribute を取得し、取得した情報をコンソール画面に書き込むことによって、説明を出力します。
' Gets the attributes for the property. Dim attributes As AttributeCollection = _ TypeDescriptor.GetProperties(Me)("MyImage").Attributes ' Prints the description by retrieving the DescriptionAttribute ' from the AttributeCollection. Dim myAttribute As DescriptionAttribute = _ CType(attributes(GetType(DescriptionAttribute)), DescriptionAttribute) Console.WriteLine(myAttribute.Description)
// Gets the attributes for the property. AttributeCollection attributes = TypeDescriptor.GetProperties(this)["MyImage"].Attributes; /* Prints the description by retrieving the DescriptionAttribute * from the AttributeCollection. */ DescriptionAttribute myAttribute = (DescriptionAttribute)attributes[typeof(DescriptionAttribute)]; Console.WriteLine(myAttribute.Description);
// Gets the attributes for the property. AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyImage" ]->Attributes; /* Prints the description by retrieving the DescriptionAttribute * from the AttributeCollection. */ DescriptionAttribute^ myAttribute = dynamic_cast<DescriptionAttribute^>(attributes[ DescriptionAttribute::typeid ]); Console::WriteLine( myAttribute->Description );
// Gets the attributes for the property. AttributeCollection attributes = TypeDescriptor.GetProperties(this). get_Item("MyImage").get_Attributes(); /* Prints the description by retrieving the DescriptionAttribute from the AttributeCollection. */ DescriptionAttribute myAttribute = (DescriptionAttribute)(attributes. get_Item(DescriptionAttribute.class.ToType())); Console.WriteLine(myAttribute.get_Description());



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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


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

<ComVisibleAttribute(False)> _ <AttributeUsageAttribute(AttributeTargets.Assembly Or AttributeTargets.Class Or AttributeTargets.Method Or AttributeTargets.Interface, Inherited:=True)> _ Public NotInheritable Class DescriptionAttribute Inherits Attribute
[ComVisibleAttribute(false)] [AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Interface, Inherited=true)] public sealed class DescriptionAttribute : Attribute
[ComVisibleAttribute(false)] [AttributeUsageAttribute(AttributeTargets::Assembly|AttributeTargets::Class|AttributeTargets::Method|AttributeTargets::Interface, Inherited=true)] public ref class DescriptionAttribute sealed : public Attribute


この属性の使用方法については、次のコード例を参照してください。
<Assembly: Description("A system for ensuring that the correct account balance is stored after a transaction.")>
[assembly: Description("A system for ensuring that the correct account balance is stored after a transaction.")]

System.Attribute
System.EnterpriseServices.DescriptionAttribute


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- DescriptionAttribute クラスのページへのリンク