make a property can only be set at design time

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
 
A

AHadiA

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top