如果要做,可以绑定paint事件
全局代码
Public Sub groupBox1_Paint(sender As Object, e As Windows.Forms.PaintEventArgs)
e.Graphics.Clear(Sender.BackColor)
e.Graphics.DrawString(Sender.Text, Sender.Font, Brushes.Red, 10, 1)
e.Graphics.DrawLine(Pens.Red, 1, 7, 8, 7)
e.Graphics.DrawLine(Pens.Red, e.Graphics.MeasureString(Sender.Text, Sender.Font).Width + 8, 7, Sender.Width - 2, 7)
e.Graphics.DrawLine(Pens.Red, 1, 7, 1, Sender.Height - 2)
e.Graphics.DrawLine(Pens.Red, 1, Sender.Height - 2, Sender.Width - 2, Sender.Height - 2)
e.Graphics.DrawLine(Pens.Red, Sender.Width - 2, 7, Sender.Width - 2, Sender.Height - 2)
End Sub
afterLoad事件
Dim gbx As Windows.forms.Groupbox= e.Form.Controls("GroupBox1").basecontrol
addhandler gbx.paint, addressof GroupBox1_paint