If a field’s type is TEXT ( like LONGTEXT, MEDIUMTEXT etc) and we try to show it on a DBGrid it’ll be shown like (MEMO). But everyone in the world want to show some part of the TEXT field to user. For example you want to show user first 200 characters of the TEXT field.

To solve this situation;

1. Right click on your database connection component and press “Fields Editor”
2. A panel comes to screen. Right Click to panel and press “Add Fields”
3. Select the fields you want to add.
4. After doing those click on your Field which was showing to user like (MEMO)
5. On Object Inspector click the Events tab.
6. Double click the OnGetText event.
7. Write code below to OnGetText event :


procedure TmyForm.myQuery1_MYFIELD_GetText(Sender: TField;
  var Text: String; DisplayText: Boolean);
begin
  Text := Copy(myQuery1_MYFIELD_.AsString, 1, 200);
end;

This will show on Dbgrid first 200 characters of the selected field.

Tags: , , , ,
Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>