属性值 | 含义 |
CategoryAttribute | 该属性对在Property控件中的属性按字母顺序进行归类 |
DescriptionAttribute | 其值为对每个属性的具体文字描述,将会显示在property控件的底部 |
BrowsableAttribute | 该值为是否在property控件中显示或者隐藏某个属性 |
ReadOnlyAttribute | 该值为某个属性值是否在property控件中只读 |
DefaultValueAttribute | 每个属性的默认值 |
using System.ComponentModel; |
/// Customer class to be displayed in the property grid /// /// [DefaultPropertyAttribute("Name")] public class Customer { private string _name; private int _age; private DateTime _dateOfBirth; private string _SSN; private string _address; private string _email; private bool _frequentBuyer; [CategoryAttribute("ID Settings"), DescriptionAttribute("Name of the customer")] public string Name { get { return _name; } set { _name = value; } } [CategoryAttribute("ID Settings"), DescriptionAttribute("Social Security Number of the customer")] public string SSN { get { return _SSN; } set { _SSN = value; } } [CategoryAttribute("ID Settings"), DescriptionAttribute("Address of the customer")] public string Address { get { return _address; } set { _address = value; } } [CategoryAttribute("ID Settings"), DescriptionAttribute("Date of Birth of the Customer (optional)")] public DateTime DateOfBirth { get { return _dateOfBirth; } set { _dateOfBirth = value; } } [CategoryAttribute("ID Settings"), DescriptionAttribute("Age of the customer")] public int Age { get { return _age; } set { _age = value; } } [CategoryAttribute("Marketting Settings"), DescriptionAttribute("If the customer has bought more than 10 times, this is set to true")] public bool FrequentBuyer { get { return _frequentBuyer; } set { _frequentBuyer = value; } } [CategoryAttribute("Marketting Settings"), DescriptionAttribute("Most current e-mail of the customer")] public string Email { get { return _email; } set { _email = value; } } public Customer() { } } |
private void Form1_Load(object sender, System.EventArgs e) { //创建bill对象,实例化CUSTOMER类 Customer bill = new Customer(); //赋值给属性 bill.Age = 50; bill.Address = " 114 Maple Drive "; bill.DateOfBirth = Convert.ToDateTime(" 9/14/78"); bill.SSN = "123-345-3566"; bill.Email = “bill@aol.com” bill.Name = "Bill Smith"; //将对象绑定到property控件中 propertyGrid1.SelectedObject = bill; } |
相关视频
相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么
热门文章 360快剪辑怎么使用 36金山词霸如何屏幕取词百度收购PPS已敲定!3
最新文章
微信3.6.0测试版更新了微信支付漏洞会造成哪
360快剪辑怎么使用 360快剪辑软件使用方法介酷骑单车是什么 酷骑单车有什么用Apple pay与支付宝有什么区别 Apple pay与贝贝特卖是正品吗 贝贝特卖网可靠吗
人气排行 xp系统停止服务怎么办?xp系统升级win7系统方电脑闹钟怎么设置 win7电脑闹钟怎么设置office2013安装教程图解:手把手教你安装与qq影音闪退怎么办 QQ影音闪退解决方法VeryCD镜像网站逐个数,电驴资料库全集同步推是什么?同步推使用方法介绍QQ2012什么时候出 最新版下载EDiary——一款好用的电子日记本
查看所有0条评论>>