我用下面的代碼來創建一個組框用彩色邊框:的WinForms組框
Public Class BorderGroupBox
Inherits GroupBox
Private _borderColor As Color
Private _borderWidth As Integer
Private _borderStyle As ButtonBorderStyle
...
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim tSize As Size = TextRenderer.MeasureText(Me.Text, Me.Font)
Dim borderRect As Rectangle = e.ClipRectangle
borderRect.Y = CInt((borderRect.Y + (tSize.Height/2)))
borderRect.Height = CInt((borderRect.Height - (tSize.Height/2)))
ControlPaint.DrawBorder(e.Graphics, borderRect, _borderColor, _borderWidth, _borderStyle, BorderColor, _borderWidth, _borderStyle, BorderColor, _borderWidth, _borderStyle, BorderColor, _borderWidth, _borderStyle)
Dim textRect As Rectangle = e.ClipRectangle
textRect.X = (textRect.X + 6)
textRect.Width = tSize.Width + 6
textRect.Height = tSize.Height
e.Graphics.FillRectangle(New SolidBrush(Me.BackColor), textRect)
e.Graphics.DrawString(Me.Text, Me.Font, New SolidBrush(Me.ForeColor), textRect)
End Sub
End Class
的問題是,它被放在一個滾動的容器內,並且如果是滾動邊界ISN 「T重繪正確:
在哪種類型的可滾動容器中Panel,SplitContainer? – Coder
這是一個flowlayoutpanel – Matthias
如何使這個groupbox背景顏色內部的控制器透明? –