Hi all,
I'm trying to create a control and command control them from the property, there are too many similar statements. I want to cage them in a group of properties, so I have created a class that contains the property and call them from the main property of a control class.
I have a small statement, but does not work. how to display the property in the father's property
Specific CustomForeColor in DisplayCustomProperties
Thanks for your help

using System.ComponentModel;

namespace WindowsFormsApplication1
{
   public class CustomPanel: Label 
    {
       private CustomProperties _DisplayCustomProperties;
      [Browsable(true),Category("Appearance"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] 
        public CustomProperties DisplayCustomProperties
        {
            get
            {
                return _DisplayCustomProperties;
            }
            set
            {
                _DisplayCustomProperties = value;
            }
        }
     }
}



using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

namespace WindowsFormsApplication1
{
    public abstract class CustomProperties 
    {
        public enum ArrowColor { Red, Green, Magenta, Pink, Orange, Black, Yellow };
        protected CustomPanel _cpl;
        public CustomProperties(CustomPanel cpl)
        {
            this._cpl = cpl;
        }

        private ArrowColor _CustomForeColor;
        [Browsable(true), Category("Appearance")]
        public ArrowColor CustomForeColor{
            get { return _CustomForeColor; }
            set { _CustomForeColor = value; }
        }
    }
}

Recommended Answers

All 2 Replies

Did you know that an automatically implemented property syntax exists?

 private ArrowColor _CustomForeColor;
        [Browsable(true), Category("Appearance")]
        public ArrowColor CustomForeColor{
            get { return _CustomForeColor; }
            set { _CustomForeColor = value; }
        }

        // Can be written as(just 2 lines)

        [Browsable(true), Category("Appearance")]
        public ArrowColor CustomForeColor{ get; set; }

See also example 6 on this site
This syntax was added to C#, just for such cases with alot of properties in the same class.

Thanks, but I'm want is how the property nested 2 and they appear in properties
I write all the commands and put them in a class, and then just call them to a command in another class it is assigned with a control.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.