4、,使得开发自己的Windows窗体控件变得相对简单。二、编写简单的自定义控件2.1、简单控件例子下面的示例创建一个简单控件,该控件通过处理Paint事件显示其Text属性的值。为了创建此控件和处理事件,必须创建一个从Control继承的类,并创建一个重写OnPaint方法的方法。public class HelloWorldControl : Control {protected override void OnPaint(PaintEventArgs e) { RectangleF rect = new RectangleF(C
5、lientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height); e.Graphics.DrawString(this.Text, Font, new SolidBrush(ForeColor