class MyText : System.Windows.Forms.TextBox
    {
        public MyText() 
        {
        }        protected override void OnPaint(PaintEventArgs e)
        {
            // Call the OnPaint method of the base class.
            base.OnPaint(e);
            // Call methods of the System.Drawing.Graphics object.
            e.Graphics.FillRectangle(new SolidBrush(Color.LightGray), this.ClientRectangle);
            e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), ClientRectangle);
        } 
    }界面上:
 private void InitializeComponent()
        {
            this.textBox1 = new MyText();// System.Windows.Forms.TextBox();
            this.SuspendLayout();
            // 
            // textBox1
            // 
            this.textBox1.Location = new System.Drawing.Point(45, 48);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(100, 21);
            this.textBox1.TabIndex = 0;
.........
为什么,类MyText的OnPaint不被调用??