centering text (vertically) on tabs

Posted by: rgreene on 8 September 2017, 12:39 pm EST

  • Posted 8 September 2017, 12:39 pm EST

    I've created SheetNames that consist of two lines of text (by putting a newline in the middle of the string), and doubled the size of the HorizontalScrollBarHeight to make both lines visible on the sheet tabs.  However, the text is slightly cut off at the bottom, while there is still significant empty space above the first line.

    Is there any way to force the tab text to be vertically centered within the tab?

  • Replied 8 September 2017, 12:39 pm EST

    There are no alignment properties associated with the TabStrip.  I will look into this further to see if there is a way to work around this and if not I will add it as an enhancement for a future version.
  • Replied 8 September 2017, 12:39 pm EST

    After a quick test it appears that you have to have the height of the scrollbar of sufficient size to accomodate the text...

    FpSpread1.Sheets.Count = 3
    FpSpread1.HorizontalScrollBarHeight = 60
    FpSpread1.Sheets(0).SheetName = "Test " & vbLf & "Height"

    I will write the alignment properties up as an enhancement.
  • Replied 8 September 2017, 12:39 pm EST


    Thanks for looking into this.  That would be a nice enhancement.

  • Replied 8 September 2017, 12:39 pm EST

    One option with the current version is to use the PaintTabStripTab events and render the sheet tab yourself. With that option you could align the text however you wished.

  • Replied 8 September 2017, 12:39 pm EST

    Where is the PaintTabStripTab event documented?  I don't see it mentioned in the help file.

  • Replied 8 September 2017, 12:39 pm EST

    It was added in version 3.
  • Replied 8 September 2017, 12:39 pm EST

    This is sample to set text align in a cell: :)


    1. Create a custom render

    <SPAN class=kwd>Public Class</SPAN> CustomRender : <SPAN class=kwd>Implements</SPAN> IRenderer
    <SPAN class=kwd>#Region <SPAN class=st>" Variable "</SPAN></SPAN>
    <SPAN class=kwd>Private</SPAN> _paddingLeft <SPAN class=kwd>As Integer
    Private</SPAN> _paddingRight <SPAN class=kwd>As Integer
    #End Region

    Public Sub New</SPAN>(<SPAN class=kwd>ByVal</SPAN> paddLeft <SPAN class=kwd>As Integer</SPAN>, <SPAN class=kwd>ByVal</SPAN> paddRight <SPAN class=kwd>As Integer</SPAN>)

    <SPAN class=kwd>Public Sub</SPAN> PaintCell

    dRect = <SPAN class=kwd>New</SPAN> Rectangle(r.Left + _paddingLeft, r.Top + (r.Height - (appearance.Font.Height + 20)) \ 2, _
    r.Width - (_paddingLeft + _paddingRight), appearance.Font.Height + 20)
    g.DrawString(s, appearance.Font, <SPAN class=kwd>New</SPAN> SolidBrush(appearance.SelectionForeColor), dRect, strFormat)

    <SPAN class=kwd>End Sub</SPAN>

    2. And using it with

    .Cells(editRow, CreatedDateCol).Renderer = centerRender

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels