ReadOnlyAttribute(Boolean) コンストラクター
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
ReadOnlyAttribute クラスの新しいインスタンスを初期化します。
public:
ReadOnlyAttribute(bool isReadOnly);
public ReadOnlyAttribute(bool isReadOnly);
new System.ComponentModel.ReadOnlyAttribute : bool -> System.ComponentModel.ReadOnlyAttribute
Public Sub New (isReadOnly As Boolean)
パラメーター
- isReadOnly
- Boolean
true この属性がバインドされているプロパティが読み取り専用であることを示す場合。プロパティが読み取り/書き込みであることを示す false します。
例
次のコード例では、プロパティを読み取り専用としてマークします。 このコードでは、新しい ReadOnlyAttributeを作成し、その値を ReadOnlyAttribute.Yes に設定して、プロパティにバインドします。
public:
[ReadOnly(true)]
property int MyProperty
{
int get()
{
// Insert code here.
return 0;
}
void set( int value )
{
// Insert code here.
}
}
[ReadOnly(true)]
public int MyProperty
{
get =>
// Insert code here.
0;
set
{
// Insert code here.
}
}
<ReadOnlyAttribute(True)> _
Public Property MyProperty() As Integer
Get
' Insert code here.
Return 0
End Get
Set
' Insert code here.
End Set
End Property
注釈
ReadOnlyAttributeが true に設定されているか、Set メソッドを持たないメンバーは変更できません。 この属性を持たないメンバー、またはReadOnlyAttributeに設定されたfalseでマークされているメンバーは、読み取り/書き込み可能であり、変更できます。 既定値は No です。
Note
ReadOnlyAttributeを true に設定してプロパティをマークすると、この属性の値は定数メンバー Yesに設定されます。
ReadOnlyAttributeが false に設定されたプロパティの場合、値はNo。 したがって、コードでこの属性の値を確認する場合は、属性を ReadOnlyAttribute.Yes または ReadOnlyAttribute.Noとして指定する必要があります。