C# 如何绘制与System.Windows.Forms.TextBox相同的框架
在WinForms中,如何绘制与C# 如何绘制与System.Windows.Forms.TextBox相同的框架,c#,winforms,textbox,frame,visual-styles,C#,Winforms,Textbox,Frame,Visual Styles,在WinForms中,如何绘制与System.Windows.Forms.TextBox控件中相同的框架 我尝试将VisualStyleRenderer与VisualStyleElement.TextBox.TextEdit.Normal参数一起使用,但它绘制了一条奇怪的灰色线 按钮的VisualStyleElement.Button.Button.Normal功能正常。 它与按钮一样绘制面,但对于TextBox它绘制一条灰线边框 我使用了以下代码: private void panel1_Pa
System.Windows.Forms.TextBox
控件中相同的框架
我尝试将VisualStyleRenderer
与VisualStyleElement.TextBox.TextEdit.Normal
参数一起使用,但它绘制了一条奇怪的灰色线
按钮的VisualStyleElement.Button.Button.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.DruckGround
Try
var renderer=新的VisualStyleRenderer(“编辑”,6,1)代码>后接渲染器.drauckground(如图形、矩形)代码>参见使用6,3获得蓝色边框。@HansPassant哦,wunderbar,或者对你来说,那是wonderlijk…@Lars-Hehe,不完全是荷兰语中的“神秘化”意思。嗯,可能是你的意思,他们如何摸索VSR有点神秘:)VisualStyleRenderer(“编辑”,6,1)工作。谢谢你,拉尔斯。