change font of cell when editing

TeeGrid VCL / FMX for Embarcadero RAD Studio, Delphi, C++ Builder and Lazarus Free Pascal.
Post Reply
MTG
Newbie
Newbie
Posts: 3
Joined: Wed Dec 27, 2023 12:00 am

change font of cell when editing

Post by MTG » Mon Feb 19, 2024 8:05 pm

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!

MTG
Newbie
Newbie
Posts: 3
Joined: Wed Dec 27, 2023 12:00 am

Re: change font of cell when editing

Post by MTG » Tue Feb 20, 2024 8:48 am

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;

Post Reply