One of my buttons on a form needs to show vertical text like that:
S
T
O
P
I found solutions involving overriding Paint that seems too complicated for such a simple task. I tried this:
Private Sub LabelStopButton()
Dim btTitle As String = "S" & vbCrLf & "T" & vbCrLf & "O" & vbCrLf & "P" & vbCrLf
Me.btnStop.Text = btTitle
End Sub
and also tried replacing vbCrLf with: vbCr, vbLf, Environment.NewLine - to no avail, same result: only the first letter "S" is showing on the button. See image.
Using Visual Studio 2008 (this is an app for an old WinCE 6.0 device).
Any advice? Thanks!
This is a duplcate of an existing question
See https://stackoverflow.com/a/7661057/2319909
Converted code for reference:
You need to set the button to allow multiple lines. This can be achieved with following P/Invoke code.
Private Const BS_MULTILINE As Integer = &H2000
Private Const GWL_STYLE As Integer = -16
<System.Runtime.InteropServices.DllImport("coredll")> _
Private Shared Function GetWindowLong(hWnd As IntPtr, nIndex As Integer) As Integer
End Function
<System.Runtime.InteropServices.DllImport("coredll")> _
Private Shared Function SetWindowLong(hWnd As IntPtr, nIndex As Integer, dwNewLong As Integer) As Integer
End Function
Public Shared Sub MakeButtonMultiline(b As Button)
Dim hwnd As IntPtr = b.Handle
Dim currentStyle As Integer = GetWindowLong(hwnd, GWL_STYLE)
Dim newStyle As Integer = SetWindowLong(hwnd, GWL_STYLE, currentStyle Or BS_MULTILINE)
End Sub
Use it like this:
MakeButtonMultiline(button1)