I have a table with a RTF field in it.
How can I display this in a TDBGrid so that it actually shows the rich text, and not just (FMTMEMO) in the column?
I really don't want to use a third party component for this.
Thanks!
I've done a very crude example for you that works, which you can then take on to try and improve as you need.
Drop a TDBRichEdit control onto your form and set its Visible property to False. Set the DataSource and DataField properties to pick up the appropriate field.
Say the field name that holds the RTF text is called "RTF":
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
DrawState: Integer;
DrawRect: TRect;
begin
if (gdFocused in State) then
begin
if (Column.Field.FieldName = 'RTF') then
with DBRichEdit1 do
begin
Left := Rect.Left + DBGrid1.Left + 1;
Top := Rect.Top + DBGrid1.Top + 1;
Visible := True;
end;
end;
end;
procedure TForm1.DBGrid1ColExit(Sender: TObject);
begin
if DBGrid1.SelectedField.FieldName = 'RTF' then
DBRichEdit1.Visible := False;
end;
This will show the full, formatted richedit text in a popup window when you click on the column in the grid. When you click away, it hides the popup window.