Page 1 of 1

change font of cell when editing

Posted: Mon Feb 19, 2024 8:05 pm
by 18697358
Hi again,

Does anybody know how to change the cell font if user edits the cell. I cannot find font properties in edit mode similar to those in other property categories.

Probably someone has a clue for this?
thank you in advance for your help!

Re: change font of cell when editing

Posted: Tue Feb 20, 2024 8:48 am
by 18697358
Found it - very easy! This is a code snippet which copies all cell font settings equally to the column properties:

Code: Select all

procedure TMainForm.TeeGridCellEditing(const Sender: TObject;
  const AEditor: TControl; const AColumn: TColumn; const ARow: Integer);
begin
  if Assigned(AEditor) then begin
    (AEditor as TEdit).StyledSettings := [];
    // copy cell style)
    case AColumn.TextAlign.Horizontal of
      THorizontalAlign.Left: (AEditor as TEdit).TextSettings.HorzAlign := TTextAlign.Leading;
      THorizontalAlign.Center: (AEditor as TEdit).TextSettings.HorzAlign := TTextAlign.Center;
      THorizontalAlign.Right: (AEditor as TEdit).TextSettings.HorzAlign := TTextAlign.Trailing;
    end;
    case AColumn.TextAlign.Vertical of
      TVerticalAlign.Top: (AEditor as TEdit).TextSettings.VertAlign := TTextAlign.Leading;
      TVerticalAlign.Center: (AEditor as TEdit).TextSettings.VertAlign := TTextAlign.Center;
      TVerticalAlign.Bottom: (AEditor as TEdit).TextSettings.VertAlign := TTextAlign.Trailing;
    end;
    (AEditor as TEdit).Font.Size := AColumn.Format.Font.Size;
    (AEditor as TEdit).FontColor := GRIDCOLOR_FLEX_COLUMN_EDIT;
    (AEditor as TEdit).Font.Style := [TFontStyle.fsBold];
  end;
end;