表单上的一个按钮需要显示如下的垂直文本:
取值
Ť
0
P
我找到了涉及覆盖Paint的解决方案,这对于这么简单的任务来说似乎太复杂了。我试过这个:
Private Sub LabelStopButton()
Dim btTitle As String = "S" & vbCrLf & "T" & vbCrLf & "O" & vbCrLf & "P" & vbCrLf
Me.btnStop.Text = btTitle
End Sub
并尝试将vbCrLf替换为:vbCr,vbLf,Environment.NewLine - 无济于事,结果相同:只有第一个字母" S"正在按钮上显示。 See image
使用Visual Studio 2008(这是旧版WinCE 6.0设备的应用程序)。
有什么建议吗? 谢谢!
答案 0 :(得分:2)
这是现有问题的重复内容
请参阅https://stackoverflow.com/a/7661057/2319909
转换代码以供参考:
您需要将按钮设置为允许多行。这可以通过以下P / Invoke代码来实现。
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
像这样使用:
MakeButtonMultiline(button1)