EhLib.Com
https://forum.ehlib.com/en/

Display of null values
https://forum.ehlib.com/en/viewtopic.php?f=5&t=981
Page 1 of 1

Author:  halted [ 03 Jun 2019, 22:04 ]
Post subject:  Display of null values

Hi,

how is it possible to display 'NULL' in the cells when the values in the dataset are null ?
(no column is defined, i do not know at design time the number of columns)

Regards

Halted

Author:  halted [ 04 Jun 2019, 09:46 ]
Post subject:  Re: Display of null values

I answer to myself just in case it's useful for someone ;o)

procedure TframeSql.gridResultDrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState);
var
lnWidth : integer;
begin
if field.IsNull then with (Sender as TDBGridEh) do begin
Canvas.Font.Color := clDkGray;
// Canvas.Font.Style := [fsItalic];
lnWidth := Canvas.TextWidth('NULL');
Canvas.TextOut(Rect.Left + (Rect.Width - lnWidth) div 2 ,Rect.Top +1 ,'NULL');
end;
end;

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/