Access level for a property

G

Guest

I want to confirm my understanding about access modifier for property.

Assembly One contains:

Class One has Protected property Protected1_prop
Class Two has Friend property Friend2_prop
Class Three has Protected Friend property Protected_Friend3_prop
Class Four has Private property Private4_prop
Class Derived_One is a class derived from Class One of Assembly One
Class Derived_Two is a class derived from Class Two of Assembly One
Class Derived_Three is a class derived from Class Three of Assembly One
Class Derived_Four is a class derived from Class Four of Assembly One

Assembly Two contains:

Class Derived_One is a class derived from Class One of Assembly One
Class Derived_Two is a class derived from Class Two of Assembly One
Class Derived_Three is a class derived from Class Three of Assembly One
Class Derived_Four is a class derived from Class Four of Assembly One

Protected1_prop can be accessed by code in:
-Class One of Assembly One
-Class Derived_One of Assembly One
-Class Derived_One of Assembly Two

Friend2_prop can be accessed by code in:
-Assembly One

Protected_Friend3_prop can be accessed by code in:
-Assembly One
-Class Derived_Three of Assembly Two

Private4_prop can be accessed by code in:
-Class Four of Assembly One

It seems that Property Windows can only access Public properties.

Is that a way to declare a property of a custom windows control (control
inherited from existing windows control or composite control) so that only
the form containing the instance of that control can access that property.
 
P

Phill W.

Peter said:
I want to confirm my understanding about access modifier for property.

<snip>

Your understanding is the same as mine so, hopefully, we're both right. :)
It seems that Property Windows can only access Public properties.

No, they should handle the Protected ones as well.
Indeed, /many/ properties on the /standard/ Controls are inherited from
other classes, e.g. Location and Size come from the Control class.
Is that a way to declare a property of a custom windows control (control
inherited from existing windows control or composite control) so that only
the form containing the instance of that control can access that property.

Place the Control on the Form and make its Modifier "Private".

HTH,
Phill W.
 

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