




















对教材p120部分创建控件进行演示
1
using System;
2
using System.Drawing;
3
using System.ComponentModel;
4
using System.Windows.Forms;
5
6
namespace my_control
7
{
8
//所有控件必须派生自Control类
9
public class CustomControl : System.Windows.Forms.Control
10
{
11
//重载控件的OnPaint方法
12
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
13
{
14
//绘制字符串
15
e.Graphics.DrawString("Written with GDI+ on OnPaint event",
16
new Font("Arial",12), new SolidBrush(Color.Red), 0, 0);
17
}
18
}
19
}
完整控件代码和控件测试程序下载:my_control.rar
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。