将一篇代码稍稍改动了一点:
1using System.ComponentModel;
2using System.Windows.Forms;
3using System.Drawing;
4
5namespace 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}
2using System.Windows.Forms;
3using System.Drawing;
4
5namespace 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}
The end.