You can customize the appearance of the filter bar. You can change the background and text colors and the grid lines and their color. The following figure illustrates a filter bar with a custom appearance.
The filter bar also provides a date picker to pick a date to filter by. Certain filter menu choices will display the date picker (before or after, for example). You can also type the value in the edit portion of the filter after you select a filter menu option.
Setting the AutoFormat property to true specifies to use the DateTimeFormatInfo, FormatString, and NumberFormatInfo properties to format the value in the filter bar. Set these properties if the format of the data in the cell is different from the format in the filter bar. The Equals filter menu option requires that the cell format and the filter bar format be the same.
Using Code
- To customize specific cells in the filter bar, set the FilterBar class's Cells properties.
- To customize the filter bar overall, set the FilterBar's DefaultStyle, Height, HorizontalGridLine, and VerticalGridLine properties.
Example
The following example sets one cell in the filter bar to display a custom border and background color, and the entire filter bar to display a custom border.
C# | Copy Code |
---|---|
FarPoint.Win.Spread.SheetView sheetView = fpSpread1.ActiveSheet; sheetView.AutoFilterMode = FarPoint.Win.Spread.AutoFilterMode.FilterBar; sheetView.FilterBar.Cells[0].Border = new FarPoint.Win.DoubleLineBorder(Color.Red); sheetView.FilterBar.Cells[0].BackColor = Color.GreenYellow; sheetView.FilterBar.DefaultStyle.Border = new FarPoint.Win.DoubleLineBorder(Color.Yellow); |
VB | Copy Code |
---|---|
Dim sheetView As FarPoint.Win.Spread.SheetView = FpSpread1.ActiveSheet sheetView.AutoFilterMode = FarPoint.Win.Spread.AutoFilterMode.FilterBar sheetView.FilterBar.Cells(0).Border = New FarPoint.Win.DoubleLineBorder(Color.Red) sheetView.FilterBar.Cells(0).BackColor = Color.GreenYellow sheetView.FilterBar.Cells(0).CellType = New FarPoint.Win.Spread.CellType.FilterBarCellType() sheetView.FilterBar.DefaultStyle.Border = New FarPoint.Win.DoubleLineBorder(Color.Yellow) |