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 가져옵니다.

그런 다음 코드는 해당 AttributeCollection 속성의 ReadOnlyAttribute 값으로 설정하고 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

적용 대상

추가 정보