|
|
Title | Use the ReadOnly attribute in VB .NET |
Description | This example shows how to use the ReadOnly attribute in VB .NET. |
Keywords | ReadOnly, attribute, VB.NET, property |
Categories | VB.NET |
|
|
The ReadOnly attribute tells property editors such as the Properties window that a property should be considered read-only. In this example, the Properties displays the EmployeeOfTheMonth property grayed out and will not let the developer change its value.
|
|
Private m_EmployeeOfTheMonth As String = "Rod Stephens"
<[ReadOnly](True)> _
Public Property EmployeeOfTheMonth() As String
Get
Return m_EmployeeOfTheMonth
End Get
Set(ByVal Value As String)
m_EmployeeOfTheMonth = Value
End Set
End Property
|
|
Note that ReadOnly is a Visual Basic keyword so the system gets confused if you use thaht name alone. To indicate that it is not being used as a keyword, enclose it in [square brackets] as shown here.
|
|
|
|
|
|