0

I am trying to build out an application that has tabs on the left, but I want the text to be horizontal and not vertical. I have seen many forum posts for WPF and C#, but nothing specific to VB.net.

Is there a specific property I can use to have the text change from vertical to horizontal? How do I implement this type of change? I know this seems novice like to be asking, but I feel I have hit a brick wall. Any help would be greatly appreciated.

John D
  • 139
  • 13
  • Just emulate it with Label controls. You can still use TabPages by [hiding the tabs](https://stackoverflow.com/a/6954785/17034). – Hans Passant Feb 28 '18 at 13:21

1 Answers1

0

I was able to find the following on the .Net Resource page for Microsoft.

https://learn.microsoft.com/en-us/dotnet/framework/winforms/controls/how-to-display-side-aligned-tabs-with-tabcontrol

The only item I now want to be able to do is add in padding to the text so that its not right against the dialog box. If anyone has any ideas, please advise.

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
John D
  • 139
  • 13