Results 1 to 4 of 4

Thread: [2.0] Create Sub Property

  1. #1

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Question [2.0] Create Sub Property

    Hi all
    How to create sub property


    Code:
    public class control
    {
     private bool first;
        public bool one1
        {
            get
            {
                return _one1;
            }
            set
            {
                _one1 = value;
            }
        }
    }
    Above code creting single property and we can set this property

    Code:
    control.one1=false
    But can we create sub property like in this way


    Code:
    control.one1.visible=false
    control.one1.Caption="shakti"
    Because we can see this property in Label class

    Code:
    Label.Visible=False
    Label.Caption="My Name"
    Hope you got my problem
    Thanks

  2. #2
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: [2.0] Create Sub Property

    Code:
    private bool first;
    
    public bool one1
    {
        get { return first; }
        set { one1 = value; }
    }
    There an example property now whats the problem again though sorry? Sub property?

    Do you mean some sort of constructor?

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2.0] Create Sub Property

    You can have one1 as a class of its own with those properties in it, then give control a property of type one1.

    You can also perform something in the get/set block, so if your control exposes the text property, have that property set the label's text property.

  4. #4
    Hyperactive Member
    Join Date
    Mar 2001
    Location
    Calgary, Canada
    Posts
    453

    Re: [2.0] Create Sub Property

    Do you mean creating a child class within a class? I'm not clear on the question, sorry.

    But If create a class called control.

    Then within that class, you can create a new class called one1 which has properties of .visible and .caption.

    You can now reference Control.one1.visible and Control.one1.Caption.

    Is that what you are looking for?

    (aha upon rereading - this is what our resident three eyed frog just suggested - which just goes to prove the addage that great minds drink alike.)
    "I'd rather have a full bottle in front of me than a full frontal lobotomy!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width