I need a text box with a bottom line, such as the input fields used in forms.
I was looking for functionality, such as a single border at the bottom, or something like that. But I think the only way is to draw one line in the text box.
The following code does not work:
private void textEdit1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
if (sender is TextBox)
{
TextBox tmp = (TextBox)sender;
Graphics g = CreateGraphics();
Pen p = new Pen(System.Drawing.Color.Red, 8);
g.DrawLine(p, tmp.Location.X, tmp.Location.Y, (tmp.Location.X + tmp.Width), tmp.Location.Y);
p.Dispose();
g.Dispose();
}
}
Hope someone can help! Thank!
source
share