Drawing an outline around a label
Posted on 2004-10-13
I would like some assistance with comeing up with some code. I want to use the code below to paint a solid rectangle on a form, on the rectangle I will have a label with text in it, I want to draw a colored rectangle around the label as if it was the label's border when the mouse enters (hovers) over the label. This should simulate the way Microsoft works with their menu's when the mouse hovers over the text or picture in the label it will paint the outline around the control. It's the best I could think up to use without paying $300.00 for a control that will do all the work. My way is free so to speak.
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim Brush1 As SolidBrush = New SolidBrush(Color.InactiveCaptionText)
'first num is margin left side, second is margin top, third is leingth of box, fourth is height of box.
g.FillRectangle(Brush1, 3, 3, 50, 50)