Skip to main content

Format Cells Dialog

  • 7 minutes to read

The ExpressSpreadSheet provides the built-in Format Cells dialog that allows an end-user to adjust the formatting of the currently focused Table View cell or selected cell ranges:

Format Cells Dialog

This dialog is invoked when you call the ShowFormatCellsDialog procedure that is implemented in the dxSpreadSheetFormatCellsDialog unit. This method has only one obligatory parameter. It specifies a Table View instance to which the formatting should be applied. An optional second parameter allows you to specify which tab of the displayed dialog is active.

An end-user can invoke the Format Cells dialog for the currently active worksheet either by clicking the Format Cells… item in the cell context menu or by pressing the Ctrl+1 key combination:

Cell Context Menu

Every time an end-user invokes the dialog window, it displays the tab which was active at the moment of its last use, with only two exceptions:

  • If an end-user invokes the Format Cells dialog for the first time either by using the cell context menu or by pressing the Ctrl+1 combination, the dialog window is displayed with the active Number tab;

  • If an end-user presses the Ctrl+Shift+P key combination, the Format Cells dialog is displayed with the active Font tab.

With this dialog an end-user can specify the content format, alignment and style of the border and background. The Format Cells dialog has six corresponding tabs:

  • Number

  • Alignment

  • Font

  • Border

  • Fill

  • Protection

Number

The Number page displays the range of formats supported by ExpressSpreadSheet. These formats are divided into several groups according to types of values to which the format can be applied. For instance, the Date group contains the set of formats related to displaying date values.

Number Page

Use the list box at the Category panel to quickly select the required group of formats.

You can apply formatting by selecting the required format type from the Type panel and then clicking the OK button.

The Sample panel allows you to see the results of text formatting before applying styles to worksheet data. Whenever you change settings on the tab, the sample string is redrawn with the potential changed settings.

To display the Format Cells dialog window with the active Number tab, call the ShowFormatCellsDialog global procedure with the AActivePage parameter set to 0. If this parameter is unspecified, the Number page is also active only when the dialog appears for the first time.

Alignment

This page allows an end-user to:

Alignment

Horizontal text alignment

General
Aligns the cell contents according to its type. Numerical values are aligned to the right, a text is aligned to the left, and logical values are centered.
Left (Indent)
The content is left aligned. The indent value specifies the space (in pixels) between the left cell border and the content.
Center
The content is centered.
Right (Indent)
The content is right aligned. The indent value specifies the space (in pixels) between the right cell border and the cell content.
Fill
Truncates the cell text if it is too long for the cell width.
Justify
Justifies the text so that words are distributed evenly between the left and right cell edges.
Distributed (Indent)
Distributes the cell contents across the width of the cell. The indent value (in pixels) applies both left and right sides of the cell.

Vertical text alignment

Top
Aligns the text to the top.
Center
The cell text is centered vertically.
Bottom
Aligns the text to the bottom of a cell.
Justify
Justifies the text vertically so that lines are distributed evenly between the top and bottom edges.
Distributed
Distributes the cell contents across the height of the cell.

This page also allows an end-user to change text control settings:

  • Wrap text check box controls whether the text in a cell is displayed in several lines if it is too long for the cell width. If set to off, the text is truncated at the end of the first line, even if there is space for more lines.

  • Shrink to fit check box controls whether the text is reduced to fit the cell width if it is too long. This setting is an alternative to the text wrapping, thus only one of these two check boxes can be active at the same time.

Additionally, by using the Merge cells check box, you can merge and unmerge cells within a selected area.

To display the Format Cells dialog window with the active Alignment tab, call the ShowFormatCellsDialog global procedure with the AActivePage parameter set to 1. The default value of this parameter corresponds to the active Number page or a page active at the moment of the dialog’s last use.

Font

This page allows an end-user to select the font, its size, style, color, and font effects for contents of a selected cell.

Font Settings

The effect of all font settings specified in list boxes and combo boxes on this page is immediately displayed in the Preview panel, allowing you to estimate and correct your customization before applying it to worksheet cell data.

To display the Format Cells dialog window with the active Font tab, call the ShowFormatCellsDialog global procedure with the AActivePage parameter set to 2. The default value of this parameter corresponds to the active Number page or a page active at the moment of the dialog’s last use.

An end-user can invoke the Format Cells dialog with the active Font tab by pressing the Ctrl+Shift+P key combination.

Border

The Border page allows an end-user to modify the cell border style and color.

Border Settings

The edge styles are presented in the Line panel.

Line Style Settings

Click a specific line on the panel and then apply it to a required border. You can perform this in two ways:

  • Using the nine buttons arranged around the sample cells panel;

  • Clicking near the border on the sample cells panel.

The None button clears all the border formatting of the selection.

None Button

The Outline button outlines the selection with the border style specified.

Outline Button

The Inside button applies the formatting to the internal cell edges within the selected cell. This button is disabled if only one cell is provided to the dialog.

Inside Button

There are six more buttons, which specify formatting of specific borders only, namely:

  • The top border of the cell range

Top Edge

  • Internal horizontal borders

Horizontal Border

  • The bottom border of the cell range

Bottom Edge

  • The left border of the cell range

Left Edge

  • Internal vertical borders

Vertical Border

  • The right border of the cell range

Right Edge

You can specify the color of the borders via the Color combo box.

Color

To display the Format Cells dialog with the active Border tab, call the ShowFormatCellsDialog with the AActivePage parameter set to 3. The default value of this parameter corresponds to the active Number page or a page active at the moment of the dialog’s last use.

Fill

The Fill page contains control elements that allow an end-user to specify both the background and foreground colors, and the brush fill pattern for the selected cells (or cell ranges).

Cell Fill Settings

The Background color panel enables an end-user to assign the base background color of the cell brush:

Background Color Pattern

To assign the foreground color of the cell brush, use the Pattern color combo box:

Foreground Color Pattern

The Pattern style combo box allows you to apply a particular fill pattern style:

Fill Pattern

Finally, the Sample panel displays the cell brush preview corresponding to the selected cell fill parameters:

Cell Brush Preview

To display the Format Cells dialog with the active Fill tab, call the ShowFormatCellsDialog with the AActivePage parameter set to 4. The default value of this parameter corresponds to the active Number page or a page active at the moment of the dialog’s last use.

Protection

The Protection page contains Locked and Hidden check boxes that affect the selected cells only if the entire worksheet is protected.

Cell Protection Settings

To display the Format Cells dialog with the active Protection tab, call the ShowFormatCellsDialog with the AActivePage parameter value that exceeds 4. The default value of this parameter corresponds to the active Number page or a page active at the moment of the dialog’s last use.