• 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中

  • 相关阅读:
    C# TCP异步服务/客户端
    Entity Framework Batch Update and Future Queries
    用c#编写socks代理服务器,大白话细述协议的最重要部分。
    ArraySegment AsEnumerable
    c#数据包拦截+网络编程
    为.Net Remoting增加基于SKYPE API的P2P传输通道
    如何看PDA的IP
    基本搞定PDA HTTP Server
    PDA SOAP Server探索历程(1)
    疑难问题之PDA SOAP Server
  • 原文地址:https://www.cnblogs.com/bear831204/p/1415695.html
Copyright © 2020-2023  润新知