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中

  • 相关阅读:
    Linux环境定时备份mysql数据库
    idea以DEBUG方式启动项目卡住,但是不报错
    Linux查看防火墙,开放端口
    element动态添加删除表格的行数
    触发器编写,执行插入或update分别执行不同sql
    vue数组判断数值,遍历,过滤
    将某文件夹下的文件压缩成zip
    转载:win10专业版取消自动更新
    IIS启动应用程序池报错"服务无法在此时接受控制信息
    IIS7 设置网站默认主页(首页)
  • 原文地址:https://www.cnblogs.com/bear831204/p/1415695.html
Copyright © 2011-2022 走看看