Autofilter icon missing when columnheader celltype set to HeaderCell

Posted by: harriscohen1 on 8 September 2017, 1:44 pm EST

  • Posted 8 September 2017, 1:44 pm EST

    Hello,

    I am using GetPreferredWidth to size the columns in my spread, however, some of the data fields are smaller than the column header text, so I use the following:

            Dim HeaderCell As New FarPoint.Win.Spread.CellType.TextCellType
            HeaderCell.WordWrap = False

                For i = 0 To fpSpread1.ActiveSheet.ColumnCount - 1
                    fpSpread1.Sheets(0).ColumnHeader.Columns(i).CellType = HeaderCell
                    fpSpread1.ActiveSheet.Columns(i).Width = fpSpread1.ActiveSheet.Columns(i).GetPreferredWidth
                Next

    But when I do this, the Autofilter icon (the funnel) disappears. When I comment out the line which sets the columnheader celltype it works fine.  How can I make the Autofilter icon appear when I use the code above?

    Thank you,
    L. Cohen
     

  • Replied 8 September 2017, 1:44 pm EST

    Hello,

    You may try not setting the cell type of column header explicitly (in case of bound sheet) to any type and instead use the following snippet to get the AutoFilter icon display on the columh header:

     FpSpread1.ActiveSheet.Columns(2).AllowAutoFilter = True

    where 2 is the index of columns

    Thanks

    Suresh

  • Replied 8 September 2017, 1:44 pm EST

    Thanks but then the GetPreferredWidth does not render correctly due to the column header length.
  • Replied 8 September 2017, 1:44 pm EST

    I should clearly state that I already set the AllowAutofilter = True.
  • Replied 8 September 2017, 1:44 pm EST

    Here is a forum post with more information:

    http://www.clubfarpoint.com/Forums/forums/post/44839.aspx

  • Replied 8 September 2017, 1:44 pm EST

    Hello,


    As long as you turn off the WOrdWrap property on the Renderer of the cell, then the GetPreferredWidth method should work to return the correct size, even with a filter and/or sort indicator.


    Dim enh As New FarPoint.Win.Spread.CellType.EnhancedColumnHeaderRenderer


    enh.WordWrap = False


    FpSpread1.Sheets(0).ColumnHeader.DefaultStyle.Renderer = enh


    FpSpread1.Sheets(0).Columns(1).Width = FpSpread1.Sheets(0).Columns(1).GetPreferredWidth()

Need extra support?

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

Learn More

Forum Channels