Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleUse the ReadOnly attribute in VB .NET
DescriptionThis example shows how to use the ReadOnly attribute in VB .NET.
KeywordsReadOnly, attribute, VB.NET, property
CategoriesVB.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.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated