Topic: Change Grid Font

Hello Dmitry

I would like allow to end user to modify if he wants police for the grid.
In addition, the user will pass through a FontDialog
I use for it this code

function LoadFont: TFont;
var reg: TRegistry;
begin
     result := TFont.Create;
     reg    := TRegistry.Create;
     reg.Access  := KEY_ALL_ACCESS;
     reg.RootKey := HKEY_CURRENT_USER;

     if reg.OpenKey('software\Diabet', true) then
     begin
          if reg.ValueExists('Font.Name') then result.Name := Reg.ReadString('Font.Name');
          if reg.ValueExists('Font.Size') then result.Size := Reg.ReadInteger('Font.Size');

          if reg.ValueExists('Font.Style.fsBold') then
              if Reg.ReadBool('Font.Style.fsBold') then result.Style := result.Style + fsBold;
          if reg.ValueExists('Font.Style.fsItalic') then
              if Reg.ReadBool('Font.Style.fsItalic') then result.Style := result.Style + fsItalic;
          if reg.ValueExists('Font.Style.fsUnderline') then
              if Reg.ReadBool('Font.Style.fsUnderline') then result.Style := result.Style + fsUnderline;
          if reg.ValueExists('Font.Style.fsStrikeOut') then
              if Reg.ReadBool('Font.Style.fsStrikeOut') then result.Style := result.Style + fsStrikeOut;
          reg.CloseKey;
     end;
     reg.Free;
end;

procedure SaveFont(Font: TFont);
var reg: TRegistry;
begin
     reg         := TRegistry.Create;
     reg.Access  := KEY_ALL_ACCESS;
     reg.RootKey := HKEY_CURRENT_USER;

     if reg.OpenKey('software\Diabet', true) then
     begin
          Reg.WriteString('Font.Name', Font.Name);
          Reg.WriteInteger('Font.Size', Font.Size);
          Reg.WriteBool('Font.Style.fsBold', fsBold in [Font.Style]);
          Reg.WriteBool('Font.Style.fsItalic', fsItalic in [Font.Style]);
          Reg.WriteBool('Font.Style.fsUnderline', fsUnderline in [Font.Style]);
          Reg.WriteBool('Font.Style.fsStrikeOut', fsStrikeOut in [Font.Style]);
          reg.CloseKey;
     end;
     reg.Free;
end;

The only one modification applies upon column header, but no impact about font for all text into the grid.

Does this MVD version (2.8 beta) allows this modification or is it yet impossible ?

Thanks Dmitry for your answer

JB

Re: Change Grid Font

Hi. jean.brezhonek

Um... how to use

function LoadFont: TFont;
...

  in project  ???  or apply for change all font in tablegrid,combobox ???
Please Show  Example ... For We And My Student  Education
Thank You Very Much.

My Visual Database : I Love You
Easy For Beginner Student For Me

Re: Change Grid Font

jean.brezhonek
Just call method

Form1.TableGrid1.dbUpdate; 

After update font.


An example:

Post's attachments

Attachment icon Font change.zip 17.11 kb, 546 downloads since 2016-10-03 

Dmitry.

Re: Change Grid Font

Hello Dmitry

Thanks for your help


Hello PrahouseFamily

To use LoadFont and SaveFont,, you can look at for example given by Dmitry (Fontchange.zip).
It makes the job without any difficulty and is very efficient.

JB

Re: Change Grid Font

Thank You jean.brezhonek and Dmitry for quesion and answer
It Easy code ! and minimal   My student have very fun

var
    FontDialog: TFontDialog;
begin
    FontDialog := TFontDialog.Create(Form1);
    FontDialog.Font := Form1.GridEmployees.Font;
    if FontDialog.Execute then
    begin
        Form1.GridEmployees.Font:= FontDialog.Font;
        Form1.GridEmployees.dbUpdate;
        //SaveFont(Form1.GridEmployees.Font);
    end;
end;
My Visual Database : I Love You
Easy For Beginner Student For Me