Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


checkbox vertical text

ergoergo Member Posts: 3

I have need of a checkbox with vertical text and decided to make my first attempt at a simple custom control class. The graphical portion of the checkbox is rendered, but no text is visible. Any thought on whatI am overlooking or doing wrong?

`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
        Return _VerticalText
    End Get
    Set(ByVal value)
        _VerticalText = value
    End Set
End Property

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
    'Call DrawStringRectangleFFormat(pevent)
    Dim cx As Single = (Left + Right) / 2
    Dim cy As Single = (Top + Bottom) / 2
    Dim g As Graphics = e.Graphics
    Dim fnt As Font = MyBase.Font  'added
g.DrawString(_VerticalText, fnt, Brushes.Black, New Rectangle(cx, cy, 100, 20), fmt)

End Sub

End Class`


Sign In or Register to comment.