Imports System.Drawing.Drawing2D Imports System.Drawing.Text Protected Overrides Sub OnPaint(ByVal pe As System.Windows.Forms.PaintEventArgs) ' パネルを描画する DrawPanel(pe.Graphics) ' 基本クラスOnPaintは実行しない 'MyBase.OnPaint(pe) End Sub Private Sub DrawPanel(ByVal g As Graphics) Dim rectPaint As Rectangle = Me.ClientRectangle If (rectPaint.Width <= 0) Or (rectPaint.Height <= 0) Then Return ' 描画しない End If ' 内部の背景を描画 rectPaint.Inflate(-2, -2) Dim brushBackground As New LinearGradientBrush(rectPaint, Me.BackColor, Color.White, LinearGradientMode.ForwardDiagonal) g.FillRectangle(brushBackground, rectPaint) brushBackground.Dispose() ' 描画時に線幅分右にはみ出るので、それを差し引いておく rectPaint.Width = rectPaint.Width - 1 rectPaint.Height = rectPaint.Height - 1 ' 内枠の白線を描画 rectPaint.Inflate(1, 1) g.DrawRectangle(New Pen(Color.White, 1), rectPaint) ' 外枠の背景色の線を描画 rectPaint.Inflate(1, 1) g.DrawRectangle(New Pen(Me.BackColor, 1), rectPaint) ' 文字列を描画 Dim brushText As New SolidBrush(Me.ForeColor) g.TextRenderingHint = TextRenderingHint.AntiAlias g.DrawString(Me.panelTitleText, Me.Font, brushText, 10, 10) brushText.Dispose() End Sub