ReadOnlyAttribute.IsReadOnly 속성

정의

이 특성이 바인딩되는 속성이 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

public:
 property bool IsReadOnly { bool get(); };
public bool IsReadOnly { get; }
member this.IsReadOnly : bool
Public ReadOnly Property IsReadOnly As Boolean

속성 값

이 특성이 바인딩되는 속성이 읽기 전용이면 true이고, 속성이 읽기/쓰기이면 false입니다.

예제

다음 코드 예제에서는 가 읽기 전용인지 여부를 MyProperty 확인합니다. 먼저 코드는 다음을 수행하여 에 대한 MyProperty 특성을 가져옵니다.

그런 다음 코드는 의 값을 ReadOnlyAttributeAttributeCollection 로 설정하고 myAttribute 속성이 읽기 전용인지 여부를 확인합니다.

// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyProperty" ]->Attributes;

// Checks to see whether the property is read-only.
ReadOnlyAttribute^ myAttribute = dynamic_cast<ReadOnlyAttribute^>(attributes[ ReadOnlyAttribute::typeid ]);
if ( myAttribute->IsReadOnly )
{
   // Insert code here.
}
// Gets the attributes for the property.
AttributeCollection attributes = 
   TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;

// Checks to see whether the property is read-only.
ReadOnlyAttribute myAttribute = 
   (ReadOnlyAttribute)attributes[typeof(ReadOnlyAttribute)];

if(myAttribute.IsReadOnly) {
   // Insert code here.
}
' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
   TypeDescriptor.GetProperties(Me)("MyProperty").Attributes
       
' Checks to see whether the property is read-only.
Dim myAttribute As ReadOnlyAttribute = _
   CType(attributes(GetType(ReadOnlyAttribute)), ReadOnlyAttribute)
   
If myAttribute.IsReadOnly Then
    ' Insert code here.
End If

적용 대상

추가 정보