Recent

Author Topic: [solved] TDBGrid : add text in a cellule  (Read 848 times)

folkeu08

  • Full Member
  • ***
  • Posts: 106
[solved] TDBGrid : add text in a cellule
« on: August 06, 2020, 07:08:29 pm »
Hi,
The field that I display in a cell is declared as interger in MySQL database.
They are displayed in a column of a TDBGrid.
I would like to add to the display the value "months' to get "36 months".
I don't tell you how to do this because there is no "addtext" field in the column.
Thanks
François
« Last Edit: August 18, 2020, 06:12:02 pm by folkeu08 »

balazsszekely

  • Guest
Re: TDBGrid : add text in a cellule
« Reply #1 on: August 06, 2020, 08:29:22 pm »
Hi François,

Double click the query which is linked to the dbgrid. Select the integer field, then go to the Object Inspector->Events->OnGetText. Create the event, then:
Code: Pascal  [Select][+][-]
  1. procedure TfMain.SQLQuery1GetText(Sender: TField; var aText: string;
  2.   DisplayText: Boolean);
  3. begin
  4.   aText := IntToStr(Sender.AsInteger) + '  months';
  5. end;  

folkeu08

  • Full Member
  • ***
  • Posts: 106
Re: TDBGrid : add text in a cellule
« Reply #2 on: August 07, 2020, 02:00:50 pm »
Very tanks, it's good.
François

« Last Edit: August 18, 2020, 06:11:43 pm by folkeu08 »

 

TinyPortal © 2005-2018