BrowsableAttribute 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
속성 또는 이벤트를 속성 창에 표시해야 할지 여부를 지정합니다.
public ref class BrowsableAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All)]
public sealed class BrowsableAttribute : Attribute
public sealed class BrowsableAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All)>]
type BrowsableAttribute = class
inherit Attribute
type BrowsableAttribute = class
inherit Attribute
Public NotInheritable Class BrowsableAttribute
Inherits Attribute
- 상속
- 특성
예제
다음 예제에서는 속성을 검색 가능으로 표시합니다.
public:
[Browsable(true)]
property int MyProperty
{
int get()
{
// Insert code here.
return 0;
}
void set( int value )
{
// Insert code here.
}
}
[Browsable(true)]
public int MyProperty
{
get
{
// Insert code here.
return 0;
}
set
{
// Insert code here.
}
}
<Browsable(True)> _
Public Property MyProperty() As Integer
Get
' Insert code here.
Return 0
End Get
Set
' Insert code here.
End Set
End Property
다음 예제에서는 값을 확인 하는 방법을 보여 줍니다 합니다 BrowsableAttribute 에 대 한 MyProperty
합니다. 첫째, 코드는 개체에 대한 모든 속성을 가진 값을 가져옵니다 PropertyDescriptorCollection . 다음으로, 코드는 가져올 MyProperty
인덱싱합니다PropertyDescriptorCollection. 그런 다음이 속성에 대 한 특성을 반환 하 고 특성 변수에 저장 합니다.
이 예제에서는 값을 확인 하는 두 가지 방법을 제공 합니다 BrowsableAttribute합니다. 두 번째 코드 조각에서 예제는 메서드를 호출합니다 Equals . 마지막 코드 조각에서 사용 하 여는 Browsable 속성 값을 확인 합니다.
// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyProperty" ]->Attributes;
// Checks to see if the value of the BrowsableAttribute is Yes.
if ( attributes[ BrowsableAttribute::typeid ]->Equals( BrowsableAttribute::Yes ) )
{
// Insert code here.
}
// This is another way to see whether the property is browsable.
BrowsableAttribute^ myAttribute = dynamic_cast<BrowsableAttribute^>(attributes[ BrowsableAttribute::typeid ]);
if ( myAttribute->Browsable )
{
// Insert code here.
}
// Gets the attributes for the property.
AttributeCollection attributes =
TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;
// Checks to see if the value of the BrowsableAttribute is Yes.
if (attributes[typeof(BrowsableAttribute)].Equals(BrowsableAttribute.Yes))
{
// Insert code here.
}
// This is another way to see whether the property is browsable.
BrowsableAttribute myAttribute =
(BrowsableAttribute)attributes[typeof(BrowsableAttribute)];
if (myAttribute.Browsable)
{
// Insert code here.
}
' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
TypeDescriptor.GetProperties(Me)("MyProperty").Attributes
' Checks to see if the value of the BrowsableAttribute is Yes.
If attributes(GetType(BrowsableAttribute)).Equals(BrowsableAttribute.Yes) Then
' Insert code here.
End If
' This is another way to see whether the property is browsable.
Dim myAttribute As BrowsableAttribute = _
CType(attributes(GetType(BrowsableAttribute)), BrowsableAttribute)
If myAttribute.Browsable Then
' Insert code here.
End If
사용 하 여 클래스를 표시 하는 경우는 BrowsableAttribute, 값을 확인 하려면 다음 코드를 사용 합니다.
AttributeCollection^ attributes = TypeDescriptor::GetAttributes( MyProperty );
if ( attributes[ BrowsableAttribute::typeid ]->Equals( BrowsableAttribute::Yes ) )
{
// Insert code here.
}
AttributeCollection attributes =
TypeDescriptor.GetAttributes(MyProperty);
if (attributes[typeof(BrowsableAttribute)].Equals(BrowsableAttribute.Yes))
{
// Insert code here.
}
Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(MyProperty)
If attributes(GetType(BrowsableAttribute)).Equals(BrowsableAttribute.Yes) Then
' Insert code here.
End If
설명
시각적 개체 디자이너는 일반적으로 검색 가능한 특성이 없거나 생성자의 browsable
매개 변수true
가 설정된 멤버를 BrowsableAttribute 속성 창 표시됩니다. 이러한 멤버는 디자인 타임에 수정할 수 있습니다. BrowsableAttribute 생성자의 browsable
매개 변수가 설정된 false
멤버는 디자인 타임 편집에 적합하지 않으므로 시각적 디자이너에 표시되지 않습니다. 기본값은 true
입니다.
참고
속성을 Browsable(true)
표시하면 이 특성의 값이 상수 멤버 Yes로 설정됩니다. 표시된 Browsable(false)
속성의 경우 값은 .입니다 No. Therefore, when you check the value of this attribute in your code, you must specify the attribute as BrowsableAttribute.Yes or BrowsableAttribute.No.
자세한 내용은 특성을 참조하세요.
생성자
BrowsableAttribute(Boolean) |
BrowsableAttribute 클래스의 새 인스턴스를 초기화합니다. |
필드
Default |
BrowsableAttribute의 기본값인 Yes을 지정합니다. 이 |
No |
디자인 타임에서 속성 또는 이벤트를 수정할 수 없도록 지정합니다. 이 |
Yes |
디자인 타임에서 속성 또는 이벤트를 수정할 수 있도록 지정합니다. 이 |
속성
Browsable |
찾아볼 수 있는 개체인지 여부를 나타내는 값을 가져옵니다. |
TypeId |
파생 클래스에서 구현된 경우 이 Attribute에 대한 고유 식별자를 가져옵니다. (다음에서 상속됨 Attribute) |
메서드
Equals(Object) |
이 인스턴스와 지정된 개체가 같은지 여부를 나타냅니다. |
GetHashCode() |
이 인스턴스의 해시 코드를 반환합니다. |
GetType() |
현재 인스턴스의 Type을 가져옵니다. (다음에서 상속됨 Object) |
IsDefaultAttribute() |
이 특성이 기본값인지 여부를 확인합니다. |
IsDefaultAttribute() |
파생 클래스에서 재정의된 경우 이 인스턴스 값이 파생 클래스에 대한 기본값인지 여부를 표시합니다. (다음에서 상속됨 Attribute) |
Match(Object) |
파생 클래스에서 재정의된 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다. (다음에서 상속됨 Attribute) |
MemberwiseClone() |
현재 Object의 단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |
명시적 인터페이스 구현
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다. (다음에서 상속됨 Attribute) |
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다. (다음에서 상속됨 Attribute) |
_Attribute.GetTypeInfoCount(UInt32) |
개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1). (다음에서 상속됨 Attribute) |
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다. (다음에서 상속됨 Attribute) |