Readonly at runtime

  • Thread starter Thread starter elziko
  • Start date Start date
E

elziko

How do I make a property of a class Readonly but only at RUNTIME?

I want to be able to edit the value in a property browser after dragging my
component on a form but then not allow any code to change this property when
the code is running.

TIA
 
elziko said:
How do I make a property of a class Readonly but only at RUNTIME?

Untested:

\\\
Public Property...
...
Set(ByVal Value As Foo)
If Me.DesignMode Then
m_Foo = Value
End If
End Set
End Property
///
 
Elziko,
I would modify Herfried's slightly:

Public Property...
...
Set(ByVal Value As Foo)
If Me.DesignMode Then
m_Foo = Value
Else
Throw New NotSupportedException
End If
End Set
End Property

Which will give a glaring runtime error if you attempt to set the property.

Hope this helps
Jay
 
Back
Top