I use the following code to get a TextBox that does not draw its borders:
public partial class CustomTextBox : TextBox
{
public CustomTextBox()
{
InitializeComponent();
SetStyle(ControlStyles.UserPaint, true);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
int borderWidth = 1;
ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle,
Color.Transparent, borderWidth, ButtonBorderStyle.Solid,
Color.Transparent, borderWidth, ButtonBorderStyle.Solid,
Color.Transparent, borderWidth, ButtonBorderStyle.Solid,
Color.Transparent, borderWidth, ButtonBorderStyle.Solid);
}
}
I seem to be missing something inside OnPaint () because my Font is no longer the default font for the text field (maybe I need to override another event).
When checking the CustomTextBox.Font property, it shows me, by default, “Microsoft SansSerif at 8.25”, but when entering text into my text block, the font definitely looks bigger and bold.
I hope you help me!
Hello,
Inno
[EDIT]
, OnPaint, CustomTextBox . OnPaint ( ).
, - , OnPaint ( ATM , ).