다음을 통해 공유


CategoryAttribute 클래스

항목별 모드로 설정된 PropertyGrid 컨트롤에 표시될 때 속성이나 이벤트를 그룹화할 범주 이름을 지정합니다.

네임스페이스: System.ComponentModel
어셈블리: System(system.dll)

구문

‘선언
<AttributeUsageAttribute(AttributeTargets.All)> _
Public Class CategoryAttribute
    Inherits Attribute
‘사용 방법
Dim instance As CategoryAttribute
[AttributeUsageAttribute(AttributeTargets.All)] 
public class CategoryAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::All)] 
public ref class CategoryAttribute : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.All) */ 
public class CategoryAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.All) 
public class CategoryAttribute extends Attribute

설명

CategoryAttributeCategorized 모드로 설정된 PropertyGrid 컨트롤에 속성이나 이벤트를 나열할 때 연관된 속성이나 이벤트와 연결할 범주를 나타냅니다. 속성 또는 이벤트에 CategoryAttribute가 적용되지 않았으면 PropertyGrid는 해당 속성 또는 이벤트를 기타 범주와 연결합니다. CategoryAttribute의 생성자에서 범주 이름을 지정하여 모든 이름에 대해 새 범주를 만들 수 있습니다.

Category 속성은 특성이 나타내는 범주의 이름을 표시합니다. 또한 Category 속성은 범주 이름의 투명한 지역화를 제공합니다.

상속자 참고 사항 미리 정의된 범주 이름 이외의 이름을 사용하여 범주 이름을 지역화하려면 GetLocalizedString 메서드를 재정의해야 합니다. 또한 Category 속성을 재정의하여 지역화에 대한 사용자 지정 논리를 제공할 수도 있습니다. CategoryAttribute 클래스는 다음과 같은 일반 범주를 정의합니다.

범주

설명

Action

사용 가능한 작업과 관련된 속성입니다.

Appearance

엔터티의 표시 방식과 관련된 속성입니다.

Behavior

엔터티의 동작 방식과 관련된 속성입니다.

Data

데이터 및 데이터 소스 관리와 관련된 속성입니다.

Default

기본 범주로 그룹화되는 속성입니다.

Design

디자인 타임에서만 사용할 수 있는 속성입니다.

DragDrop

끌어서 놓기 작업과 관련된 속성입니다.

Focus

포커스와 관련된 속성입니다.

Format

형식 지정과 관련된 속성입니다.

Key

키보드와 관련된 속성입니다.

Layout

레이아웃과 관련된 속성입니다.

Mouse

마우스와 관련된 속성입니다.

WindowStyle

최상위 폼의 창 스타일과 관련된 속성입니다.

자세한 내용은 특성 개요특성을 사용하여 메타데이터 확장을 참조하십시오.

항목 위치
연습: 사용자 지정 서버 컨트롤 개발 및 사용 Authoring ASP.NET Controls
ASP.NET 1.1용 사용자 지정 데이터 바인딩 웹 서버 컨트롤 개발 Authoring ASP.NET Controls
ASP.NET 2.0용 사용자 지정 데이터 바인딩 웹 서버 컨트롤 개발 Authoring ASP.NET Controls
연습: ASP.NET 2.0용 사용자 지정 데이터 바인딩 ASP.NET 웹 컨트롤 만들기 Authoring ASP.NET Controls
연습: ASP.NET 1.1용 사용자 지정 데이터 바인딩 ASP.NET 웹 컨트롤 만들기 Authoring ASP.NET Controls
연습: 사용자 지정 서버 컨트롤 개발 및 사용 Visual Web Developer를 사용하여 응용 프로그램 빌드
ASP.NET 1.1용 사용자 지정 데이터 바인딩 웹 서버 컨트롤 개발 Visual Studio에서 ASP .NET 웹 응용 프로그램 빌드
연습: ASP.NET 1.1용 사용자 지정 데이터 바인딩 ASP.NET 웹 컨트롤 만들기 Visual Studio에서 ASP .NET 웹 응용 프로그램 빌드
ASP.NET 2.0용 사용자 지정 데이터 바인딩 웹 서버 컨트롤 개발 Visual Studio에서 ASP .NET 웹 응용 프로그램 빌드
연습: ASP.NET 2.0용 사용자 지정 데이터 바인딩 ASP.NET 웹 컨트롤 만들기 Visual Studio에서 ASP .NET 웹 응용 프로그램 빌드
ASP.NET 1.1용 사용자 지정 데이터 바인딩 웹 서버 컨트롤 개발 Visual Studio에서 ASP .NET 웹 응용 프로그램 빌드
ASP.NET 2.0용 사용자 지정 데이터 바인딩 웹 서버 컨트롤 개발 Visual Studio에서 ASP .NET 웹 응용 프로그램 빌드
연습: ASP.NET 2.0용 사용자 지정 데이터 바인딩 ASP.NET 웹 컨트롤 만들기 Visual Studio에서 ASP .NET 웹 응용 프로그램 빌드
연습: ASP.NET 1.1용 사용자 지정 데이터 바인딩 ASP.NET 웹 컨트롤 만들기 Visual Studio에서 ASP .NET 웹 응용 프로그램 빌드

예제

다음 예제에서는 MyImage 속성을 만듭니다. 이 속성에는 DescriptionAttributeCategoryAttribute의 두 가지 특성이 있습니다.

<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.
    }
 }
   [Description("The image associated with the control"),Category("Appearance")]
   System::Drawing::Image^ get()
   {
      // Insert code here.
      return m_Image1;
   }

   void set( System::Drawing::Image^ )
   {
      // 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를 가져옵니다. 그런 다음 이 속성의 특성을 반환하여 attributes 변수에 저장합니다.

예제에서는 AttributeCollection에서 CategoryAttribute를 검색한 다음 이를 콘솔 화면에 쓰는 방법으로 범주를 출력합니다.

' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
    TypeDescriptor.GetProperties(Me)("MyImage").Attributes

' Prints the description by retrieving the CategoryAttribute. 
' from the AttributeCollection.
Dim myAttribute As CategoryAttribute = _
    CType(attributes(GetType(CategoryAttribute)), CategoryAttribute)
    Console.WriteLine(myAttribute.Category)
// Gets the attributes for the property.
 AttributeCollection attributes = 
    TypeDescriptor.GetProperties(this)["MyImage"].Attributes;
 
 // Prints the description by retrieving the CategoryAttribute.
 // from the AttributeCollection.
 CategoryAttribute myAttribute = 
    (CategoryAttribute)attributes[typeof(CategoryAttribute)];
 Console.WriteLine(myAttribute.Category);
// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyImage" ]->Attributes;

// Prints the description by retrieving the CategoryAttribute.
// from the AttributeCollection.
CategoryAttribute^ myAttribute = static_cast<CategoryAttribute^>(attributes[ CategoryAttribute::typeid ]);
Console::WriteLine( myAttribute->Category );
// Gets the attributes for the property.
AttributeCollection attributes = TypeDescriptor.GetProperties(this)
    .get_Item("MyImage").get_Attributes();

// Prints the description by retrieving the CategoryAttribute.
// from the AttributeCollection.
CategoryAttribute myAttribute = (CategoryAttribute)(
    attributes.get_Item(CategoryAttribute.class.ToType()));
Console.WriteLine(myAttribute.get_Category());

상속 계층 구조

System.Object
   System.Attribute
    System.ComponentModel.CategoryAttribute

스레드로부터의 안전성

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

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에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

CategoryAttribute 멤버
System.ComponentModel 네임스페이스
Attribute
PropertyDescriptor
EventDescriptor