Trying to change the Border Color of a label

后端 未结 3 1309
青春惊慌失措
青春惊慌失措 2021-01-01 10:57

I\'m working in VB, VS2008, winforms. I\'ve got some labels to create, and I\'m using the BorderStyle = FixedSingle.

Is there any way to change the color of this bo

3条回答
  •  春和景丽
    2021-01-01 11:46

    I combined the solutions from robin.ellis and orandov to get a result that worked the best for me. I created a custom control that inherited the Label object and then overrode the OnPaint event.

    Public Class nomLabel
       Inherits Label
    
      Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
          MyBase.OnPaint(e)
    
          ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, myColor, ButtonBorderStyle.Solid)
       End Sub
    
    End Class
    

    Thanks for the help!

提交回复
热议问题