zoukankan      html  css  js  c++  java
  • DesignerSerializationVisibility, Browsable,Category Attribute

             1.  DesignerSerializationVisibility

    指在design time的时候,在property grid中设置的某个属性的值是否应该插入到InitializeComponent的代码中去。

    ·         Visible 默认值,会插入中去。

    ·         Hidden 不会插入中去。

    ·         Content  将该属性中所有的为public的子属性插入中去。

    例如下面的例子:
    public partial class ContentSerializationExampleControl : UserControl
        {
            
    public ContentSerializationExampleControl()
            {
                InitializeComponent();
            }

            [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
            
    public DimensionData Dimensions
            {
                
    get
                {
                    
    return new DimensionData(this);
                }
            }

            [TypeConverterAttribute(
    typeof(System.ComponentModel.ExpandableObjectConverter))]
            
    // This attribute indicates that the public properties of this object should be listed in the property grid.
            public class DimensionData
            {
                
    private Control owner;

                
    // This class reads and writes the Location and Size properties from the Control which it is initialized to.
                internal DimensionData(Control owner)
                {
                    
    this.owner = owner;
                }

                
    public Point Location
                {
                    
    get
                    {
                        
    return owner.Location;
                    }
                    
    set
                    {
                        owner.Location 
    = value;
                    }
                }

                
    public Size FormSize
                {
                    
    get
                    {
                        
    return owner.Size;
                    }
                    
    set
                    {
                        owner.Size 
    = value;
                    }
                }
            }
        }
    则DimensionData的Location和FormSize属性都会出现在InitializeComponent中。

    2. Category:指定属性出现在property grid中的哪个组中。
    3. Browsable:指定属性是否显示在property grid中

  • 相关阅读:
    css基础--Display(显示) and Visibility(可见性)and position (定位)
    css3基础--Margin(外边距)&&padding(外边距)
    前端求职-js
    前端求职-html&css
    css基础3--box module&Border
    css基础-font&link&list属性
    值得学习的PHP
    c++构造函数浅析
    变量定义原则
    函数
  • 原文地址:https://www.cnblogs.com/bear831204/p/1415695.html
Copyright © 2011-2022 走看看