Display text field in dbgrid Delphi

Asked

Viewed 1,122 times

1

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

Note: I cannot change the Database field of text for varchar, and have also seen some posts talking about the OnGetText but I couldn’t find where this event is...

Follows print: inserir a descrição da imagem aqui

1 answer

2


Access the DataSet providing the data for the Grid, select the Field and in the events tab you will find.

Here we use as follows:

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

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 being as follows:

if (Sender.IsNull = False) then
begin
  Text := 'Texto desejado'
end
else
begin
  Text := 'Não existe dados gravados'
end;
  • Thank you so much Junior, you’ve helped me so much !!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.