在默认情况下继承TextBox的控件,OnPaint是不会响应的,必须这样
public class MyTextBox : System.Windows.Forms.TextBox
{
public MyTextBox()
{
SetStyle(ControlStyles.UserPaint, true);
}
g.DrawString(this.Text, this.Font, new SolidBrush(clrText), 7, 0);
}
private void DrawRoundedRectangle(Graphics g, Pen p, Rectangle rc, Size size)
{
// 1 pixel indent in all sides = Size(4, 4)
// To make pixel indentation larger, change by a factor of 4,
// i. e., 2 pixels indent = Size(8, 8);
private void DrawBorder(Graphics g, int x, int y, int width, int height)
{
g.DrawRectangle(.);
}
只是想画有个一个框的话,g.DrawImage(.........)截一个图片也是可以的。
本人已做好大部分已经美化的控件。