Articles in this section
Category / Section

How to enable wordwrap in WinForms TabControlAdv?

1 min read

Wordwrap

In  WinForms TabControlAdv, you can word wrap the TabPageAdv text by handling its DrawItem event.

C#

void tabControlAdv1_DrawItem(object sender, Syncfusion.Windows.Forms.Tools.DrawTabEventArgs drawItemInfo)
 {
    if(drawItemInfo.Graphics.MeasureString(tabText, drawItemInfo.Font).Width > WrapLength)
    {
       enableMultiLine = true;
       ArrayList list = new ArrayList();
       string[] arr = tabText.Split();
       tabText = string.Empty;
       foreach (string item in arr)
       {
          if (tabText == string.Empty)
            tabText = item + Environment.NewLine;
          else
            tabText = tabText + item;
       }
    }
    if(enableMultiLine)
    {
       tabRect = new RectangleF((float)drawItemInfo.Bounds.X, (float)drawItemInfo.Bounds.Y - 51,                                        (float)drawItemInfo.Bounds.Width, (float)drawItemInfo.Bounds.Height + 100);
    }
 }

VB

Private Sub tabControlAdv1_DrawItem(sender As Object, drawItemInfo As Syncfusion.Windows.Forms.Tools.DrawTabEventArgs)
    If drawItemInfo.Graphics.MeasureString(tabText, drawItemInfo.Font).Width > WrapLength Then
       enableMultiLine = True
       Dim list As New ArrayList()
       Dim arr As String() = tabText.Split()
       tabText = String.Empty
       For Each item As String In arr
          If tabText = String.Empty Then
             tabText = item + Environment.NewLine
          Else
             tabText = tabText & item
          End If
       Next
    End If
    If enableMultiLine Then
       tabRect = New RectangleF(CSng(drawItemInfo.Bounds.X), CSng(drawItemInfo.Bounds.Y) - 51,   CSng(drawItemInfo.Bounds.Width), CSng(drawItemInfo.Bounds.Height) + 100)
    End If
End Sub

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/TabControlAdv_MultiLine597364458.zip

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied