Setting Property

Hi,

Can I create a property that I'll be able to set his values in the Properties window

Example, the property will be called "Person", and in the Properties window I'll be able to set "Name", "Age", "Gender", exc.



Answer this question

Setting Property

  • Bodylojohn



    //some class
    //global class variables (private)
    private int theAge = 0;
    private string theName = String.Empty;
    private string theGender = String.Empty;
    ...
    //properties
    public int TheAge
    {
    get
    {
    return this.theAge;
    }
    set
    {
    this.theAge = value; //whatever value was given is passed and set here
    }
    }



  • Pigyman

    Sorry, still don't quite follow - I apologize, any chance explaining further in depth

  • Sam Hobbs

    Assuming "MyClass" is a UserControl, then you can drag it onto a form. When selected on the form, it properties will appear (and can be changed) in the property window.

  • WayneSpangler

    you didn't understood me. I'll try to explain on your example:

    I ment that in the Properties window will be a "some class" property,

    that underneath him I'll be able to set "TheAge", "TheName", "TheGender".


  • Setting Property