4、遗漏,但是基本上概括了控件的主要方面。 接下来我们做一个简单的控件来增强一下感性认识。首先启动VS2005创建一个ClassLibrary工程,命名为CustomControlSample,VS会自动为我们创建一个solution与这个工程同名,然后删掉自动生成的Class1.cs文件,最后在Solutionexplorer里右键点击CustomControlSample工程选择Add->Classes…添加一个新类,将文件的名称命名为FirstControl。下边是代码: using System;using System.Collections.Generic;usin
5、g System.Text;using System.Windows.Forms;using System.ComponentModel;using System.Drawing;namespace CustomControlSample{ public class FirstControl : Control { public FirstControl() { } // ContentAlignment is an enumeration defined in the System.Drawing // nam
6、espace that specifies the alignment of content on a drawing // surface. private ContentAlignment alignmentValue = ContentAlignment.MiddleLeft; [ Category("Alignment"), Description("Specifies the alignment of text.") ] public ContentAlignment TextAlig
7、nment { get { return alignmentValue; } set { alignmentValue = value; // The Invalidate method