private void CustomButton_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
//初始化一个GraphicsPath类的对象
System.Drawing.Drawing2D.GraphicsPath myGraphicsPath = new
System.Drawing.Drawing2D.GraphicsPath();
//确定一个字符串,该字符串就是控件的形状
string stringText = "Click Me!";
//确定字符串的字体
FontFamily family = new FontFamily("Arial");
//确定字符串的风格
int fontStyle = (int)FontStyle.Bold;
//确定字符串的高度
int emSize = 35;
//确定字符串的起始位置,它是从控件开始计算而非窗体
PointF origin = new PointF(0, 0);
//一个StringFormat对象来确定字符串的字间距以及对齐方式
StringFormat format = new StringFormat(StringFormat.GenericDefault);
//用AddString方法创建字符串
myGraphicsPath.AddString(stringText, family, fontStyle, emSize, origin, format);
//将控件的Region属性设置为上面创建的GraphicsPath对象
CustomButton.Region = new Region(myGraphicsPath);
}