您的位置:首页 > 运维架构

这几天的工作用到了Winform的PropertyGrid,说说心得~

2004-12-27 14:38 435 查看
      PropertyGrid的功能不用我多说了,看名字就可以知道个大概,在这里就谈谈它的一些功能使用。

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

this.PropTableColumn.SelectedObject = ... ;

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

假设我们目前设置了一个类ABSControlsSettings用于绑定,代码如下:

public class ABSControlsSettings

private string _ControlID;

public string ControlID

private bool _Needcheck;

public bool Needcheck

private ControlTypeEnum _ControlType = ControlTypeEnum.Label;

public ControlTypeEnum ControlType

public enum ControlTypeEnum

private ListItemCollection _ValueList = new ListItemCollection();

public ListItemCollection ValueList

    public class ListItem

    public class ListItemCollection : System.Collections.CollectionBase

这些只是一些用户扩展部分的属性定义,还有一些系统级的属性可以直接设置,如Font设置颜色等,大家可以自己去试~

总的说来,PropertyGrid是一个弹性不错的控件,灵活使用可以让我们的UI更加容易操作~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: