Felix Wu gives this solution in the microsoft.public.dotnet.frameworks.windowsforms newgroup.
You can download a VB.NET sample.
Override the OnPaint event of the TextBox. For example:
protected override void OnPaint(PaintEventArgs e)
{
SolidBrush drawBrush = new SolidBrush(ForeColor); //Use the ForeColor property
// Draw string to screen.
e.Graphics.DrawString(Text, Font, drawBrush, 0f,0f); //Use the Font property
}
Note: You need to set the ControlStyles to ”UserPaint” in the constructor.
public MyTextBox()
{
// This call is required by the Windows.Forms Form Designer.
this.SetStyle(ControlStyles.UserPaint,true);
InitializeComponent();
// TODO: Add any initialization after the InitForm call
}
Share with