Back to Devexpress

TdxSpreadSheetChangeFontSize Class

vcl-dxspreadsheetactions-e1911d70.md

latest8.2 KB
Original Source

TdxSpreadSheetChangeFontSize Class

An action object that implements the sChangeFontSize end-user command in Spreadsheet and Report Designer-based applications.

Declaration

delphi
TdxSpreadSheetChangeFontSize = class(
    TdxSpreadSheetValueAction,
    IdxActionFontSizeValue
)

Remarks

This class does not introduce any new public members. The command implemented as the TdxSpreadSheetChangeFontSize action object is designed for use in a Ribbon or Toolbar UI by a TcxComboBox item control.

Executing a TdxSpreadSheetChangeFontSize action object by clicking an item in the linked TcxComboBox UI element changes the font size used to display:

  • The values in all selected cells.
  • The text selection within an in-place cell editor (only if the rich content formatting functionality is enabled in the Spreadsheet/Report Designer control).

Handle the TdxSpreadSheetChangeFontColor action object’s OnExecute event to provide custom implementation of the ChangeFontSize command’s functionality, which is useful if you need to use it with a custom client control instead of TcxComboBox. Refer to the following code example re-implementing the command’s capability to apply a specific font size to the current cell selection:

delphi
procedure TSpreadSheetControlForm.dxSpreadSheetChangeFontSize1Execute(Sender: TObject);
var
  ATableView: TdxSpreadSheetTableView;
  ACell: TdxSpreadSheetCell;
  I, J, K: Integer; // Counters
begin
  ATableView := dxSpreadSheet1.ActiveSheetAsTable;
  if(ATableView.Selection.Count > 0) then
  begin
    ATableView.BeginUpdate; // Stops worksheet repainting until the new font size is applied to all affected cells
    for I := 0 to ATableView.Selection.Count - 1 do // Cycles through all selected cell ranges
      for J := ATableView.Selection.Items[I].Left to ATableView.Selection.Items[I].Right do // Cycles through all columns within one selected cell area
        for K := ATableView.Selection.Items[I].Top to ATableView.Selection.Items[I].Bottom do // Cycles through all rows within one selected cell area
        begin
          ACell := ATableView.CreateCell(K, J); // Obtains every cell object within one selected area
          ACell.Style.Font.Size := 16; // Here you can specify any font size instead of 16
        end;
    ATableView.EndUpdate; // Enables worksheet repainting to display the pending changes
  end;
end;
cpp
void __fastcall TSpreadSheetControlForm::dxSpreadSheetChangeFontSize1Execute(TObject *Sender)
{
  TdxSpreadSheetTableView *ATableView;
  TdxSpreadSheetCell *ACell;
  ATableView = dxSpreadSheet1->ActiveSheetAsTable;
  if(ATableView->Selection->Count > 0)
  {
    ATableView->BeginUpdate(); // Stops worksheet repainting until the new font size is applied to all affected cells
    for(int I = 0; I < ATableView->Selection->Count; I++) // Cycles through all selected cell ranges
      for(int J = ATableView->Selection->Items[I]->Left; J <= ATableView->Selection->Items[I]->Right; J++) // Cycles through all columns within one selected cell area
        for(int K = ATableView->Selection->Items[I]->Top; K <= ATableView->Selection->Items[I]->Bottom; K++) // Cycles through all rows within one selected cell area
        {
          ACell = ATableView->CreateCell(K, J); // Obtains every cell object within one selected area
          ACell->Style->Font->Size = 16; // Here you can specify any font size instead of 16
        }
  }
  ATableView->EndUpdate(); // Enables worksheet repainting to display the pending changes
}

UI elements linked to a TdxSpreadSheetChangeFontSize action object are enabled only if the following conditions are met:

If cell selection is disallowed in the protected worksheet (i.e., its OptionsProtection.ActualAllowSelectUnlockedCells property returns False), executing the TdxSpreadSheetChangeFontSize action object has no effect.

Implements

IdxActionFontSizeValue

Inheritance

Show 15 items

TObject TPersistent TComponent TBasicAction TContainedAction TCustomAction TAction TdxBasicAction TdxCustomAction TdxSpreadSheetAction TdxSpreadSheetCustomEditAction TdxSpreadSheetCustomEditCellsAction TdxSpreadSheetCustomFormatCellsAction TdxSpreadSheetValueAction TdxSpreadSheetChangeFontSize

See Also

TdxSpreadSheetChangeFillColor Class

TdxSpreadSheetChangeFontColor Class

TdxSpreadSheetIncreaseFontSize Class

TdxSpreadSheetChangeFontName Class

TdxSpreadSheetDecreaseFontSize Class

TdxSpreadSheetToggleFontStrikeout Class

TdxSpreadSheetToggleFontBold Class

TdxSpreadSheetToggleFontItalic Class

TdxSpreadSheetToggleFontUnderline Class

TdxSpreadSheetChangeFontSize Members

dxSpreadSheetActions Unit