使用自定义颜色替换/重绘TextBox 3D边框

情景

WinForms中 ,当BorderStyle属性设置为FlatNoneFixed3D时,我已经将文本 Fixed3D分类为使用纯色绘制我自己的边框。

问题

当我的TextBox属性设置为Fixed3D ,当我尝试使用颜色绘制边框时,表面上的边框未正确绘制:

在此处输入图像描述

您在图像中看到的是一个缩放的TextBox,其中包含:

BackColor =黑色

BorderStyle = Fixed3D(白色的东西)

红色的是我的边界意图。

在C#或VB.Net中,我如何替换/重绘3D边框来做我想要的?,我的意思是替换/隐藏/重绘上面图像的白色边框。

这是我在OnPaint方法上尝试过的:

  Using g As Graphics = Graphics.FromHwnd(Me.Handle) ' Dim rect As Rectangle = New Rectangle(0, 0, Me.Width, Me.Height) ' Dim pen As New Pen(Color.Black, 2) ' pen.Alignment = PenAlignment.Inset ' g.DrawRectangle(pen, rect) ControlPaint.DrawBorder(Graphics.FromHwnd(Me.Handle), Me.ClientRectangle, Me.borderColor1, ButtonBorderStyle.Solid) End Using 

我也尝试使用DrawBorder3D方法,但它的任何重载都接受一种颜色?