You can customize the style of header cells if you want to change the default appearance. Set the default style of the header cells by setting the DefaultStyle property in the RowHeader or ColumnHeader class. For more information on what can be set, refer to the StyleInfo object and the RowHeader and ColumnHeader objects in the Assembly Reference.
You can also change some of the properties of the SheetSkin class that customize the appearance of header cells and apply the skin the sheet. These properties include FlatRowHeader and FlatColumnHeader. For more information creating and applying skins, refer to Applying a Skin to a Sheet and Creating a Skin for Sheets.
When defining and applying a custom style to header cells, be sure to set the text alignment. The default renderer (without any style applied) centers the text; if you apply a style, and do not set the alignment, the text is left-aligned not centered.
You can also set the grid lines around the header cells with the Border property.
Return to Customizing the Appearance of Headers.
Using the Properties Window
- At design time, in the Properties window, select the FpSpread component.
- Select the NamedStyles Collection drop-down button.
- Add a style and set the properties.
- Click OK. Select the cells you want to apply the style to and set the StyleName property.
- Use the SheetView Collection Editor to set the DefaultStyleName for a column header, row header, column footer, or sheet corner.
- Click OK to close the editor.
Using a Shortcut
- To change the style for the column header, define a style and then set the ColumnHeader DefaultStyle property.
- To change the settings for the row header, define a style and then set the RowHeader DefaultStyle property.
Example
This example code defines a style with new colors and applies it to the column header.
C# | Copy Code |
---|---|
// Define a new style. FarPoint.Web.Spread.StyleInfo darkstyle = new FarPoint.Web.Spread.StyleInfo(); darkstyle.BackColor = Color.Teal; darkstyle.ForeColor = Color.Yellow; darkstyle.Border = new FarPoint.Web.Spread.Border(Color.Crimson); // Apply the new style. FpSpread1.ActiveSheetView.ColumnHeader.DefaultStyle = darkstyle; |
VB | Copy Code |
---|---|
' Define a new style. Dim darkstyle As New FarPoint.Web.Spread.StyleInfo() darkstyle.BackColor = Color.Teal darkstyle.ForeColor = Color.Yellow darkstyle.Border = New FarPoint.Web.Spread.Border(Color.Crimson) ' Apply the new style. FpSpread1.ActiveSheetView.ColumnHeader.DefaultStyle = darkstyle |
Using the Spread Designer
- Select the Settings menu.
- Select the Named Style icon under the Appearance Settings section.
- Use the new style icon to create a style name. Use the edit style icon to set properties for the style.
- Click OK. Close the NamedStyle dialog.
- In order to apply the style to a header, select the Header Editor icon under Other Settings. Use the Selected Header option to specify column header, row header, column footer, or sheet corner.
- Set the DefaultStyleName. Click Apply and OK.
- For cells, select the Cells, Columns, and Rows Editor.
- Select the cells you want to apply the style to.
- Set the StyleName.
- Choose Apply and OK to apply your changes to the component.
- Click Apply and Exit to close the Spread Designer.