public class MyTextBox : TextBox { public MyTextBox() { this.SetStyle(ControlStyles.UserPaint, true); } protected override void OnPaint(PaintEventArgs e) { SolidBrush myDrwBrush = new SolidBrush(Color.Black); e.Graphics.DrawString(this.Text, this.Font, myDrwBrush, 0F, 0F); } }- Instantiate an object from the new class on your form
MyTextBox myTxtBox = new MyTextBox(); myTxtBox.Location = new System.Drawing.Point(12, 36); myTxtBox.Name = "myTxtBox"; myTxtBox.Size = new System.Drawing.Size(260, 20); myTxtBox.Text = "This is a test text box"; this.Controls.Add(myTxtBox);- Disable it in your code to see the effect:
this.Controls["myTxtBox"].Enabled = falseI found the following URL useful: