Recent

Author Topic: Designing table for entering data  (Read 3541 times)

wp

  • Hero Member
  • *****
  • Posts: 13270
Re: Designing table for entering data
« Reply #15 on: January 19, 2024, 11:28:49 pm »
Why are you using the OnSetEditText event? This is meant for passing data to/from the cell editor...

Simply set the alignment when you fill the cell texts, in any order:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   sWorksheetGrid1.HorAlignment[1, 1] := haCenter;
  4.   sWorksheetGrid1.Cells[1, 1] := 'centered';
  5.  
  6.   sWorksheetGrid1.Cells[2, 2] := 'centered';
  7.   sWorksheetGrid1.HorAlignment[2, 2] := haCenter;
  8. end;  

amir.eng

  • Full Member
  • ***
  • Posts: 103
Re: Designing table for entering data
« Reply #16 on: January 20, 2024, 03:37:23 pm »
Why are you using the OnSetEditText event? This is meant for passing data to/from the cell editor...

Simply set the alignment when you fill the cell texts, in any order:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   sWorksheetGrid1.HorAlignment[1, 1] := haCenter;
  4.   sWorksheetGrid1.Cells[1, 1] := 'centered';
  5.  
  6.   sWorksheetGrid1.Cells[2, 2] := 'centered';
  7.   sWorksheetGrid1.HorAlignment[2, 2] := haCenter;
  8. end;  

Thanks, Is it possible to define a range of cells, like this :
sWorksheetGrid1.HorAlignment[A1:D10] := haCenter;
Lazarus 3.0 , FPC 3.2.2 , Windows 10 64, Excel 2016 64

wp

  • Hero Member
  • *****
  • Posts: 13270
Re: Designing table for entering data
« Reply #17 on: January 20, 2024, 04:45:25 pm »
Read https://wiki.lazarus.freepascal.org/TsWorksheetGrid#Cell_formatting, watch out for the plural versions of the format properties (HorAlignments instead of HorAlignment).

 

TinyPortal © 2005-2018