Control Properties

  • Thread starter Thread starter gwboolean
  • Start date Start date
G

gwboolean

Guest
I have created a Panel control with a border color property added.

When the control is added to a form the default is with a black, fixedsingle border. The border color can then be changed to whatever color is desired.

However, when the tool is placed on the GUI form, I only get half a border over a complete border.

It is this half border that I am able to change the border color. Anyway, my skill level has been taxed far beyond my capabilities to figure out what I need to do to just have a Panel control that defaults to a single black line. And which the border can be changed.

1596111.jpg

1596117.jpg

Imports System.Drawing.Text

Public Class SiTechPanel
Inherits System.Windows.Forms.Panel
Public Sub New()
Dim _BorderColor As Color = Color.Black
BorderStyle = BorderStyle.FixedSingle
End Sub

<System.ComponentModel.Category("Appearance")> Public Property BorderColor() As Color
Get
Return _BorderColor
End Get
Set(value As Color)
If _BorderColor <> value Then
_BorderColor = value
OnBorderColorChanged(EventArgs.Empty)
End If
End Set
End Property
Private _borderColor As Color = Color.Black

Public Event BorderColorChanged As EventHandler

Protected Overridable Sub OnBorderColorChanged(e As EventArgs)
'Repaint the control to update the colour of the border.
Refresh()
RaiseEvent BorderColorChanged(Me, e)
End Sub

Protected Overrides Sub OnPaint(e As PaintEventArgs)
MyBase.OnPaint(e)

Using p As New Pen(BorderColor)
e.Graphics.DrawRectangle(p, 0, 0, Width - 1, Height - 1)
End Using
End Sub
End Class





gwboolean

Continue reading...
 
Back
Top