how do I make a property only modifiable by code and not design time?

  • Thread starter Thread starter Lucas Sain
  • Start date Start date
L

Lucas Sain

Hi,

How do I make a property only modifiable by code and not design time. I
have a property that should only be modifieable by code and not design time,
What attribute should I use?
I tried [DesignTimeVisible(false)] but this gives me an compile error:
"Attribute 'DesignTimeVisible' is not valid on this declaration type. It is
valid on 'class, interface' declarations only."

Help is appreciated

Lucas
 
Lucas,

You will want to apply the Browsable attribute to your property, with a
value of false, to indicate that designers shouldn't modify it, like so:

[Browsable(false)]
public string MyProperty
{
get
{
}
set
{
}
}

Hope this helps.
 
Thanks,

That did the job.
Do you know how to make a code in an event not execute in design time. I
have a Baseform that has X code in the event "VisibleChanged". All my forms
inherit from this form. The code in this event always gets executed in
design time, how do I avoid this??

Regards
Lucas

Reagrds
Lucas
Nicholas Paldino said:
Lucas,

You will want to apply the Browsable attribute to your property, with a
value of false, to indicate that designers shouldn't modify it, like so:

[Browsable(false)]
public string MyProperty
{
get
{
}
set
{
}
}

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Lucas Sain said:
Hi,

How do I make a property only modifiable by code and not design time. I
have a property that should only be modifieable by code and not design time,
What attribute should I use?
I tried [DesignTimeVisible(false)] but this gives me an compile error:
"Attribute 'DesignTimeVisible' is not valid on this declaration type. It is
valid on 'class, interface' declarations only."

Help is appreciated

Lucas
 
Thanks,

That did the job.
Do you know how to make a code in an event not execute in design time. I
have a Baseform that has X code in the event "VisibleChanged". All my forms
inherit from this form. The code in this event always gets executed in
design time, how do I avoid this??

Regards
Lucas

4Space said:
[Browsable( false )] ??

Maybe?

4Space

Lucas Sain said:
Hi,

How do I make a property only modifiable by code and not design time. I
have a property that should only be modifieable by code and not design time,
What attribute should I use?
I tried [DesignTimeVisible(false)] but this gives me an compile error:
"Attribute 'DesignTimeVisible' is not valid on this declaration type. It is
valid on 'class, interface' declarations only."

Help is appreciated

Lucas
 

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

Back
Top