ReadOnlyAttribute.IsReadOnly Property

Definition

이 특성이 바인딩되는 속성이 읽기 전용인 지 여부를 나타내는 값을 가져옵니다.Gets a value indicating whether the property this attribute is bound to is read-only.

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

Property Value

Boolean

이 특성이 바인딩되는 속성이 읽기 전용이면 true이고, 속성이 읽기/쓰기이면 false입니다.true if the property this attribute is bound to is read-only; false if the property is read/write.

Examples

다음 코드 예제에서는 MyProperty이 읽기 전용인 지 여부를 확인 합니다.The following code example checks to see whether MyProperty is read-only. 첫째, 코드는 다음을 수행 하 여 MyProperty에 대 한 특성을 가져옵니다.First, the code gets the attributes for MyProperty by doing the following:

그런 다음 코드는 myAttributeAttributeCollectionReadOnlyAttribute 값으로 설정 하 고 속성이 읽기 전용인 지 여부를 확인 합니다.Then the code sets myAttribute to the value of the ReadOnlyAttribute in the AttributeCollection and checks whether the property is read-only.

// 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

Applies to

See also