我在程序中想给Panel边框重绘一下颜色,用自己的处理函数绑定了Panel控件的Paint事件。如下:
Public Shared Sub OwnDrawBorder(ByRef panel As WinForm.Panel)
Dim panelBase As Panel = panel.BaseControl
AddHandler panelBase.Paint, AddressOf Panel_DrawBorder
End Sub
Public Sub Panel_DrawBorder(sender As Object, e As PaintEventArgs)
Dim panel As Panel = CType(sender, Panel)
Const width As Integer = 1
ControlPaint.DrawBorder(
e.Graphics, panel.ClientRectangle,
Color.FromArgb(111, 157, 217), width, ButtonBorderStyle.Solid,
Color.FromArgb(111, 157, 217), width, ButtonBorderStyle.Solid,
Color.FromArgb(111, 157, 217), width, ButtonBorderStyle.Solid,
Color.FromArgb(111, 157, 217), width, ButtonBorderStyle.Solid
)
End Sub
但是跟踪了一下代码,貌似Panel控件的Paint事件并没有被触发。
难道狐表中的Panel控件基类不是标准的Panel控件吗?