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


    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

    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


    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



  • 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:

  • Replied 8 September 2017, 1:44 pm EST


    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.

    <FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Dim</FONT></FONT><FONT size=2> enh </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>New</FONT></FONT><FONT size=2> FarPoint.Win.Spread.CellType.EnhancedColumnHeaderRenderer

    enh.WordWrap = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>False

    </FONT></FONT><FONT size=2>

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

    <FONT size=2>

    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