我正在尝试构建一个左侧有标签的应用程序,但我希望文本是水平的而不是垂直的。我见过WPF和C#的很多论坛帖子,但没有特别针对VB.net。
我可以用一个特定的属性让文字从垂直变为水平吗?如何实施此类更改?我知道这似乎是新手喜欢问,但我觉得我碰到了一堵砖墙。任何帮助将不胜感激。
答案 0 :(得分:0)
我能够在Microsoft的.Net资源页面上找到以下内容。
我现在希望能够做的唯一项目是在文本中添加填充,使其在对话框中不正确。如果有人有任何想法,请告知。
Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
Dim g As Graphics = e.Graphics
Dim _TextBrush As Brush
' Get the item from the collection.
Dim _TabPage As TabPage = TabControl1.TabPages(e.Index)
' Get the real bounds for the tab rectangle.
Dim _TabBounds As Rectangle = TabControl1.GetTabRect(e.Index)
If (e.State = DrawItemState.Selected) Then
' Draw a different background color, and don't paint a focus rectangle.
_TextBrush = New SolidBrush(Color.Red)
g.FillRectangle(Brushes.Gray, e.Bounds)
Else
_TextBrush = New System.Drawing.SolidBrush(e.ForeColor)
e.DrawBackground()
End If
' Use our own font.
Dim _TabFont As New Font("Arial", 10.0, FontStyle.Bold, GraphicsUnit.Pixel)
' Draw string. Center the text.
Dim _StringFlags As New StringFormat()
_StringFlags.Alignment = StringAlignment.Center
_StringFlags.LineAlignment = StringAlignment.Center
g.DrawString(_TabPage.Text, _TabFont, _TextBrush, _TabBounds, New StringFormat(_StringFlags))
End Sub