hiding properties

  • Thread starter Thread starter ajk
  • Start date Start date
A

ajk

Hi

I was wondering how one normally does to hide standard properties in a
user control e.g. X,Y or Width. I have one approach where I have a
base object which hides some of the properties and derive from it to
hide the properties however then one always have to inherit from the
base object which is not that great in this situation. Is there some
other, more neat way?

tia
ajk
 
If I'm understanding you correctly, then no, not really. You mean, for
example, you want hide the "Size" property of a control from the designer?
Or do you want to hide it completely from developers so that they can't even
access it programmatically?

Either way, you have to derive a control from the existing one. You can't
change the attributes of existing controls.
 
i can't understand your question.

ok let me rephrase: if I create a user control and want it to be
accessible by other programmers from a toolbox. When I drop the uc on
a form in deisgn mode the properties of the control should be
controlled so that only a subset of the properties are accessible.
This is done by setting the property to Non-browsable / hidden.
In addition to show different properties of a control in design and
run mode.

tia
ajk
 
ajk said:
ok let me rephrase: if I create a user control and want it to be
accessible by other programmers from a toolbox. When I drop the uc on
a form in deisgn mode the properties of the control should be
controlled so that only a subset of the properties are accessible.
This is done by setting the property to Non-browsable / hidden.
In addition to show different properties of a control in design and
run mode.

tia
ajk

What we generally do is, if the property isn't virtual, we simply do a new
on the property like this:

[Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
EditorBrowsable(EditorBrowsableState.Never)]
public new Size AutoScrollMargin
{
get
{
return base.AutoScrollMargin;
}
set
{
base.AutoScrollMargin = value;
}
}

If it's virtual, then we simply override it and do the same.
 
ajk said:
ok let me rephrase: if I create a user control and want it to be
accessible by other programmers from a toolbox. When I drop the uc on
a form in deisgn mode the properties of the control should be
controlled so that only a subset of the properties are accessible.
This is done by setting the property to Non-browsable / hidden.
In addition to show different properties of a control in design and
run mode.

tia
ajk

What we generally do is, if the property isn't virtual, we simply do a new
on the property like this:

[Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
EditorBrowsable(EditorBrowsableState.Never)]
public new Size AutoScrollMargin
{
get
{
return base.AutoScrollMargin;
}
set
{
base.AutoScrollMargin = value;
}
}

If it's virtual, then we simply override it and do the same.

maybe i didn't understand this but this means as far i understood that
when you do a user control you explicit do the above for each property
you want to hide?

I was wondering if there was some way that when creating user
controls, that they automatically would hide properties according to
some kind of template.

or could this be solved better by having a wizard for our user
controls that automatically hides the properties?

tia
ajk
 

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