在WinForms中,如何绘制与System.Windows.Forms.TextBox
控件中相同的帧?
我尝试将VisualStyleRenderer
与VisualStyleElement.TextBox.TextEdit.Normal
参数一起使用,但它会绘制一条奇怪的灰线。
VisualStyleElement.Button.PushButton.Normal
按钮正常工作。
它像按钮一样绘制面部,但对于TextBox
,它绘制一个灰色线条边框。
我使用了以下代码:
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));
}
查看屏幕截图。
左侧是编辑和按钮控件。
右边是VisualStyleRenderer.DrawBackground