上一章遗留的DefaultValueAttribute问题,还没有找到问题所在,我会继续查找资料,找到后会及时补上。
今天我们讲Component Property Editor UI,在vs环境中Property Editor有两种,一种是vs自带的,一种是Component编写者根据自己需求而重新编写的。在本章中我们这两种都会进行一个简单的学习,vs自带的主要讲Collection Editor。
先来回顾下我们上章没有讲的几个PropertyAttribute:
EditorAttribute:指定Property Editor使用的编辑器。
DesignerSerializationVisibilityAttribute:指定通过Property Editor得到的结果是否保存在代码中。
LocalizableAttribute:用户要本地化某个窗体时,任何具有该特性的属性都将自动永久驻留到资源文件中。
代码实例如下,请注意代码中注释说明。
using
System;
using
System.Collections.Generic;
using
System.Collections;
using
System.Text;
using
System.ComponentModel;
using
System.ComponentModel.Design;
using
System.Drawing;
using
System.Drawing.Design;
using
System.Windows.Forms;
using
System.Windows.Forms.Design;
namespace
Components
![](https://i-blog.csdnimg.cn/blog_migrate/fcd5d2cd2679a90998f46d5cdd2172e4.gif)
{
// 这个例子用到了vs 2005里的List<>,如果vs 2003的朋友请自己去实做StudentCollection。
// 只要让Property的类型为继承IList的类型,其Property Editor UI都可以用vs自带的。
public class Demo3 : Component
![](https://i-blog.csdnimg.cn/blog_migrate/3051e11d68633ffca3ba64aaaa23eff6.gif)
{
public Demo3()
![](https://i-blog.csdnimg.cn/blog_migrate/3051e11d68633ffca3ba64aaaa23eff6.gif)
{
_students = new
今天我们讲Component Property Editor UI,在vs环境中Property Editor有两种,一种是vs自带的,一种是Component编写者根据自己需求而重新编写的。在本章中我们这两种都会进行一个简单的学习,vs自带的主要讲Collection Editor。
先来回顾下我们上章没有讲的几个PropertyAttribute:
EditorAttribute:指定Property Editor使用的编辑器。
DesignerSerializationVisibilityAttribute:指定通过Property Editor得到的结果是否保存在代码中。
LocalizableAttribute:用户要本地化某个窗体时,任何具有该特性的属性都将自动永久驻留到资源文件中。
代码实例如下,请注意代码中注释说明。
![](https://i-blog.csdnimg.cn/blog_migrate/3bb22f4960334250cc5b503fc2291547.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/3bb22f4960334250cc5b503fc2291547.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/3bb22f4960334250cc5b503fc2291547.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/3bb22f4960334250cc5b503fc2291547.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/3bb22f4960334250cc5b503fc2291547.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/3bb22f4960334250cc5b503fc2291547.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/3bb22f4960334250cc5b503fc2291547.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/3bb22f4960334250cc5b503fc2291547.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/3bb22f4960334250cc5b503fc2291547.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/3bb22f4960334250cc5b503fc2291547.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/3bb22f4960334250cc5b503fc2291547.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/3bb22f4960334250cc5b503fc2291547.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/fcd5d2cd2679a90998f46d5cdd2172e4.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/bde9f4cfb0a8c36d7061461c505e2c0c.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/b854634c0904529d4018c4c3336be836.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/b05c719fcde60b8adf371e34c26cccb8.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/b05c719fcde60b8adf371e34c26cccb8.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/b05c719fcde60b8adf371e34c26cccb8.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/3051e11d68633ffca3ba64aaaa23eff6.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/76522681771d7f6166b1d5c3c459dd91.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/b854634c0904529d4018c4c3336be836.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/b05c719fcde60b8adf371e34c26cccb8.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/3051e11d68633ffca3ba64aaaa23eff6.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/76522681771d7f6166b1d5c3c459dd91.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/b854634c0904529d4018c4c3336be836.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/b05c719fcde60b8adf371e34c26cccb8.gif)