make a property can only be set at design time

  • Thread starter Thread starter Ryan Liu
  • Start date Start date
R

Ryan Liu

Hi,

Is that possible to make a property to be set only at design time, not later
in code.

I need this function is because that for a self definded control, if I want
to use it on a form, the auto-generated code only take the constructor which
with no parameters.



Thanks,
Ryan Liu
 
Hi
You can use DesignTime property of the UserControl for example in the
following code snippet when setting the value of Caption property, you
must checking if it's design time or not:

Private m_caption As String
Public Property Caption() As String
Get
Return m_caption
End Get
Set(ByVal value As String)
If Me.DesignMode Then
m_caption = value
End If
End Set
End Property

I hope this helps
A.Hadi
 
Back
Top