在这里用到 属性(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.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步