DesignerAttribute クラスとは? わかりやすく解説

DesignerAttribute クラス

コンポーネント対すデザインサービス実装するために使用するクラス指定します

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Interface,
 AllowMultiple:=True, Inherited:=True)> _
Public NotInheritable Class
 DesignerAttribute
    Inherits Attribute
Dim instance As DesignerAttribute
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple=true,
 Inherited=true)] 
public sealed class DesignerAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Interface, AllowMultiple=true,
 Inherited=true)] 
public ref class DesignerAttribute sealed :
 public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface,
 AllowMultiple=true, Inherited=true) */ 
public final class DesignerAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple=true,
 Inherited=true) 
public final class DesignerAttribute extends
 Attribute
解説解説
使用例使用例

MyForm というクラス作成する方法次の例に示しますMyForm には、このクラスが DocumentDesigner を使用することを指定する DesignerAttribute と、Form カテゴリ指定する DesignerCategoryAttribute という 2 つ属性あります

<Designer("System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL",
 _
    GetType(IRootDesigner)), DesignerCategory("Form")>
 _
Public Class MyForm
    
    Inherits ContainerControl
    ' Insert code here.
End Class 'MyForm
[Designer("System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL"
,
 
    typeof(IRootDesigner)),
    DesignerCategory("Form")]
public class MyForm : ContainerControl {
    // Insert code here.
}
[Designer("System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL"
,
IRootDesigner::typeid),
DesignerCategory("Form")]
ref class MyForm: public ContainerControl{
   // Insert code here.
};
/** @attribute Designer("System.Windows.Forms.Design.DocumentDesigner,"+
    "System.Windows.Forms.Design.DLL", IRootDesigner.class)
    @attribute DesignerCategory("Form")
 */
public static class MyForm
 extends ContainerControl
{
    // Insert code here.
} //MyForm

MyFormインスタンス作成する例を次に示します。そのクラス属性取得しDesignerAttribute抽出してから、デザイナの名前を出力します

Public Shared Function Main()
 As Integer
    ' Creates a new form.
    Dim myNewForm As New
 MyForm()
    
    ' Gets the attributes for the collection.
    Dim attributes As AttributeCollection =
 TypeDescriptor.GetAttributes(myNewForm)
    
    ' Prints the name of the designer by retrieving the DesignerAttribute
    ' from the AttributeCollection. 
    Dim myAttribute As DesignerAttribute =
 _
        CType(attributes(GetType(DesignerAttribute)), DesignerAttribute)
    Console.WriteLine(("The designer for this class is: "
 & myAttribute.DesignerTypeName))
    
    Return 0
End Function 'Main
public static int Main()
 {
    // Creates a new form.
    MyForm myNewForm = new MyForm();
 
    // Gets the attributes for the collection.
    AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewForm);
 
    /* Prints the name of the designer by retrieving the DesignerAttribute
     * from the AttributeCollection. */
    DesignerAttribute myAttribute = 
       (DesignerAttribute)attributes[typeof(DesignerAttribute)];
    Console.WriteLine("The designer for this
 class is: " + myAttribute.DesignerTypeName);
  
    return 0;
}
int main()
{
   // Creates a new form.
   MyForm^ myNewForm = gcnew MyForm;

   // Gets the attributes for the collection.
   AttributeCollection^ attributes = TypeDescriptor::GetAttributes( myNewForm );

   /* Prints the name of the designer by retrieving the DesignerAttribute
       * from the AttributeCollection. */
   DesignerAttribute^ myAttribute = dynamic_cast<DesignerAttribute^>(attributes[
 DesignerAttribute::typeid ]);
   Console::WriteLine( "The designer for this
 class is: {0}", myAttribute->DesignerTypeName );
   return 0;
}
public static void main(String[]
 args)
{
    // Creates a new form.
    MyForm myNewForm = new MyForm();

    // Gets the attributes for the collection.
    AttributeCollection attributes = 
        TypeDescriptor.GetAttributes(myNewForm);

    /* Prints the name of the designer by retrieving the 
       DesignerAttribute from the AttributeCollection. 
     */
    DesignerAttribute myAttribute = (DesignerAttribute)(
        attributes.get_Item(DesignerAttribute.class.ToType()));

    Console.WriteLine(("The designer for this
 class is: " 
        + myAttribute.get_DesignerTypeName()));
} //main
継承階層継承階層
System.Object
   System.Attribute
    System.ComponentModel.DesignerAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DesignerAttribute クラス」の関連用語

DesignerAttribute クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DesignerAttribute クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS