在这里用到 属性(Attribute), 属性(Attribute)与属性(Property)不同, 前者是用来描述编程元素的,后都是用来描述对象的. 简单地说, 错了不要骂我!!!
将一篇代码稍稍改动了一点:

The end.
将一篇代码稍稍改动了一点:
1
using System.ComponentModel;
2
using System.Windows.Forms;
3
using System.Drawing;
4
5
namespace CustomControlSample
6
{
7
public class FirstControl : Control
8
{
9
private int simpleField;
10
11
[Category("我是属性,我怕谁!")]
12
[Description("我是属性,故我在(属性浏览器中)!")]
13
public int SimpleProperty
14
{
15
get { return simpleField; }
16
set { simpleField = value; }
17
}
18
19
protected override void OnPaint(PaintEventArgs e)
20
{
21
base.OnPaint(e);
22
e.Graphics.DrawRectangle(Pens.Red, new Rectangle(Point.Empty, new Size(Width - 1, Height - 1)));
23
}
24
}
25
}

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25


The end.