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

    BobM,


    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

    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

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


     

     
    1. Create a custom render

    Public Class CustomRender : Implements IRenderer
    #Region " Variable "
    Private _paddingLeft As Integer
    Private
    _paddingRight As Integer
    #End Region



    Public Sub New
    (ByVal paddLeft As Integer, ByVal paddRight As Integer)

    Public Sub PaintCell

    dRect = New 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, New SolidBrush(appearance.SelectionForeColor), dRect, strFormat)

    End Sub

     


    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