In WinForms, how to draw a frame in the same way as in a control System.Windows.Forms.TextBox?
I tried using VisualStyleRendererwith a parameter VisualStyleElement.TextBox.TextEdit.Normal, but it draws a weird gray series.
VisualStyleElement.Button.PushButton.Normalfor the button works correctly. He draws a face in the same way as a button, but for TextBoxhe draws a border with a gray line.
I used the following code:
private void panel1_Paint (object sender, PaintEventArgs e)
{
VisualStyleRenderer vsr = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Normal);
vsr.DrawBackground (e.Graphics, new Rectangle (500, 12, 100, 20));
vsr = new VisualStyleRenderer (VisualStyleElement.Button.PushButton.Normal);
vsr.DrawBackground (e.Graphics, new Rectangle (500, 47, 100, 23));
}
Take a look at the screenshot.
On the left are the Edit and Button controls.
On the right is what is painted VisualStyleRenderer.DrawBackground

source
share