Display text field in dbgrid Delphi

1

I have DBGRID , and I need to show a field of type text , but when it shows, it appears (MEMO) instead of the text that was meant to be How do I make it appear?

Note: I can not change the database field from text to varchar , and I've also seen some posts talking about OnGetText but I did not find where this event is ...

Follow print:

    
asked by anonymous 12.09.2016 / 19:24

1 answer

2

Access the DataSet that provides the data for Grid , select the corresponding Field and the events tab you will find.

Here we use the following form:

if (Sender.IsNull = False) then
begin
  Text := 'Texto desejado'
end;

There where I left 'Desired Text' you can pass as follows:

NomeDataSet.FieldByName('NomeDoField').AsString;

For Knowledge: You can still Manipulate the Event for cases that do not have data in the field, by adding a else as follows:

if (Sender.IsNull = False) then
begin
  Text := 'Texto desejado'
end
else
begin
  Text := 'Não existe dados gravados'
end;
    
13.09.2016 / 13:37