System.ComponentModel.ReadOnlyAttribute Class

Specifies whether the property this attribute is bound to is read-only or read/write. This class cannot be inherited

See Also: ReadOnlyAttribute Members

Syntax

[System.AttributeUsage(System.AttributeTargets.All)]
public sealed class ReadOnlyAttribute : Attribute

Remarks

Members that are marked with the System.ComponentModel.ReadOnlyAttribute set to true or that do not have a Set method cannot be changed. Members that do not have this attribute or that are marked with the System.ComponentModel.ReadOnlyAttribute set to false are read/write, and they can be changed. The default is ReadOnlyAttribute.No.

Note:

The System.ComponentModel.PropertyDescriptor class enforces the System.ComponentModel.ReadOnlyAttribute in the design environment and at run time. When you mark a property with the System.ComponentModel.ReadOnlyAttribute set to true, the value of this attribute is set to the constant member ReadOnlyAttribute.Yes. For a property marked with the System.ComponentModel.ReadOnlyAttribute set to false, the value is ReadOnlyAttribute.No. Therefore, when you want to check the value of this attribute in your code, you must specify the attribute as ReadOnlyAttribute.Yes or ReadOnlyAttribute.No.

For more information, see Extending Metadata Using Attributes.

Requirements

Namespace: System.ComponentModel
Assembly: System (in System.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0, 2.0.0.0, 4.0.0.0