hambakahle
Programmer
Because of screen real estate limitations, I thought checkboxes with vertical text would be useful and decided to give custom controls an inaugural attempt. Below is a simple control class: unfortunately it renders a proper checkbox graphic, but no visible text. I'd appreciate comments as to what I am overlooking or doing wrong.
Code:
Public Class VerticalCheckbox
Inherits System.Windows.Forms.CheckBox
Public Property VerticalText As String
Private fmt As New StringFormat
Public Sub New()
fmt.Alignment = StringAlignment.Center
fmt.FormatFlags = StringFormatFlags.DirectionVertical
End Sub
Public Shadows Property Text 'Overrides raiseserror
Get
Return _VerticalText
End Get
Set(ByVal value)
_VerticalText = value
End Set
End Property
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
Dim cx As Single = (Left + Right) / 2
Dim cy As Single = (Top + Bottom) / 2
Dim g As Graphics = e.Graphics
g.DrawString(_VerticalText, Font, Brushes.Black, New Rectangle(cx, cy, 100, 20), fmt)
End Sub
End Class