다음을 통해 공유


PropertyDescriptor 클래스

클래스의 속성에 대한 추상화를 제공합니다.

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

구문

‘선언
<ComVisibleAttribute(True)> _
Public MustInherit Class PropertyDescriptor
    Inherits MemberDescriptor
‘사용 방법
Dim instance As PropertyDescriptor
[ComVisibleAttribute(true)] 
public abstract class PropertyDescriptor : MemberDescriptor
[ComVisibleAttribute(true)] 
public ref class PropertyDescriptor abstract : public MemberDescriptor
/** @attribute ComVisibleAttribute(true) */ 
public abstract class PropertyDescriptor extends MemberDescriptor
ComVisibleAttribute(true) 
public abstract class PropertyDescriptor extends MemberDescriptor

설명

속성 설명은 이름, 특성, 해당 속성이 연결된 구성 요소 클래스 및 속성 형식으로 구성됩니다.

PropertyDescriptor는 다음의 속성 및 메서드를 제공합니다.

  • Converter에는 이 속성의 TypeConverter가 들어 있습니다.

  • IsLocalizable은 이 속성을 지역화해야 하는지 여부를 나타냅니다.

  • GetEditor 메서드는 지정된 형식의 편집기를 반환합니다.

PropertyDescriptor는 또한 다음과 같은 abstract 속성 및 메서드를 제공합니다.

  • ComponentType에는 이 속성이 바인딩되는 구성 요소의 형식이 들어 있습니다.

  • IsReadOnly는 이 속성이 읽기 전용인지 여부를 나타냅니다.

  • PropertyType은 속성의 형식을 가져옵니다.

  • CanResetValue 메서드는 구성 요소를 다시 설정하면 해당 구성 요소의 값이 변경되는지 여부를 나타냅니다.

  • GetValue 메서드는 구성 요소에 대한 현재 속성 값을 반환합니다.

  • ResetValue 메서드는 구성 요소의 이 속성 값을 다시 설정합니다.

  • SetValue 메서드는 구성 요소의 값을 다른 값으로 설정합니다.

  • ShouldSerializeValue 메서드는 이 속성의 값을 지속시켜야 하는지 여부를 나타냅니다.

일반적으로 abstract 멤버는 리플렉션을 통해 구현됩니다. 리플렉션에 대한 자세한 내용은 리플렉션의 항목을 참조하십시오.

참고

이 클래스에 적용되는 HostProtectionAttribute 특성의 Resources 속성 값은 SharedState입니다. HostProtectionAttribute는 대개 아이콘을 두 번 클릭하거나, 명령을 입력하거나, 브라우저에서 URL을 입력하여 시작되는 데스크톱 응용 프로그램에 영향을 미치지 않습니다. 자세한 내용은 HostProtectionAttribute 클래스나 SQL Server 프로그래밍 및 호스트 보호 특성을 참조하십시오.

예제

다음 코드 예제는 PropertyDescriptorCollection 클래스의 예제를 기반으로 작성되었습니다. 이 예제에서는 범주, 설명, 표시 이름 등의 단추 텍스트 정보를 텍스트 상자에 출력합니다. 여기에서는 폼에 button1textbox1이 인스턴스화되어 있는 것으로 가정합니다.

' Creates a new collection and assign it the properties for button1.
Dim properties As PropertyDescriptorCollection = TypeDescriptor.GetProperties(Button1)

' Sets an PropertyDescriptor to the specific property.
Dim myProperty As PropertyDescriptor = properties.Find("Text", False)

' Prints the property and the property description.
TextBox1.Text += myProperty.DisplayName & Microsoft.VisualBasic.ControlChars.Cr
TextBox1.Text += myProperty.Description & Microsoft.VisualBasic.ControlChars.Cr
TextBox1.Text += myProperty.Category & Microsoft.VisualBasic.ControlChars.Cr
// Creates a new collection and assign it the properties for button1.
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);

// Sets an PropertyDescriptor to the specific property.
System.ComponentModel.PropertyDescriptor myProperty = properties.Find("Text", false);

// Prints the property and the property description.
textBox1.Text = myProperty.DisplayName+ '\n' ;
textBox1.Text += myProperty.Description + '\n';
textBox1.Text += myProperty.Category + '\n';
// Creates a new collection and assign it the properties for button1.
PropertyDescriptorCollection^ properties = TypeDescriptor::GetProperties( button1 );

// Sets an PropertyDescriptor to the specific property.
System::ComponentModel::PropertyDescriptor^ myProperty = properties->Find( "Text", false );

// Prints the property and the property description.
textBox1->Text = String::Concat( myProperty->DisplayName, "\n" );
textBox1->Text = String::Concat( textBox1->Text, myProperty->Description, "\n" );
textBox1->Text = String::Concat( textBox1->Text, myProperty->Category, "\n" );
// Creates a new collection and assign it the properties for button1.
PropertyDescriptorCollection properties = 
    TypeDescriptor.GetProperties(button1);
// Sets an PropertyDescriptor to the specific property.
System.ComponentModel.PropertyDescriptor myProperty = 
    properties.Find("Text", false);
// Prints the property and the property description.
textBox1.set_Text(myProperty.get_DisplayName() + 'n');
textBox1.set_Text(textBox1.get_Text() + myProperty.get_Description() 
    + '\n');
textBox1.set_Text(textBox1.get_Text() + myProperty.get_Category()
    + '\n');

상속 계층 구조

System.Object
   System.ComponentModel.MemberDescriptor
    System.ComponentModel.PropertyDescriptor
       System.ComponentModel.TypeConverter.SimplePropertyDescriptor

스레드로부터의 안전성

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

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, 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에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

PropertyDescriptor 멤버
System.ComponentModel 네임스페이스
MemberDescriptor 클래스
Attribute
DefaultValueAttribute 클래스