zoukankan      html  css  js  c++  java
  • C#,Winform中PropertyGrid控件的使用

     

    PropertyGrid的功能不用我多说了,看名字就可以知道个大概,在这里就谈谈它的一些功能使用。

    假设目前有一个PropertyGrid控件PropTableColumn,那么进行属性绑定只需要一句话:

    this.PropTableColumn.SelectedObject = ... ;

    其中...表示需要进行绑定的对象,PropertyGrid使用的广泛性也主要体现在对象的设计上.

    假设我们目前设置了一个类ABSControlsSettings用于绑定,代码如下:
    public class ABSControlsSettings
        {
            public ABSControlsSettings()
            {
             }        
         }那么这个类就可以用于绑定,只是什么属性都没有而已,OK,现在我们加入一个ID属性的维护输入,其代码和加入一个普通的类属性没有什么区别
    private string _ControlID;
    public string ControlID
            {
                get { return _ControlID; }
                set { _ControlID = value; }
             }此时我们可以通过添加一系列属性来完善它,如
    CategoryAttribute("System")
    ReadOnlyAttribute(false)
    DescriptionAttribute("Controll's ID")

    这个只是最普通的属性,如果属性需要设置true or false,那么只需要这样设置
    private bool _Needcheck;
    public bool Needcheck
            {
                get { return _Needcheck; }
                set { _Needcheck = value; }
             }
    如果是一个需要进行多项选择,如同BorderStyle之类的参数,可以通过枚举属性来实现
    private ControlTypeEnum _ControlType = ControlTypeEnum.Label;
    public ControlTypeEnum ControlType
            {
                get { return _ControlType; }
                set { _ControlType = value;}
             }
    public enum ControlTypeEnum
    {
            /**//// <summary>
            /// 标签
            /// </summary>
             Label = 1,
            /**//// <summary>
            /// 文本框
            /// </summary>
             TextBox = 2
    }

  • 相关阅读:
    (转)dubbo远程调用细节
    (转)Dubbo扩展点实现细节
    (转)dubbo design
    (转) java中try/catch性能和原理
    mybatis入门基础(九)----逆向工程
    客观评价下软件培训机构
    mybatis入门基础(八)-----查询缓存
    mybatis入门基础(七)----延迟加载
    mybatis入门基础(六)----高级映射(一对一,一对多,多对多)
    为什么我不推荐大家去外包公司
  • 原文地址:https://www.cnblogs.com/furenjian/p/3084512.html
Copyright © 2011-2022 走看看