Is there any way to show a selected DBGrid record record in a memo? I tried this type of code but this shows the titles of the columns and I want to show the fields' text.
procedure TForm6.btnShowClick(Sender: TObject);
var
l: String;
p: Integer;
i: Integer;
m: String;
begin
m:='';
for p := 0 to dbGrid1.Columns.Count - 1 do
m:=m+(format('%s',[dbGrid1.Columns[p].Title.Caption]))+lm;
Memo1.Lines.Add(m);
if Dbgrid1.SelectedRows.Count>0 then
begin
with dbgrid1.DataSource.DataSet do
begin
l:=' ';
GoToBookMark(tBookmark(dbGrid1.SelectedRows[i]));
for p := 0 to Dbgrid1.Columns.Count - 1 do
begin
l:=l+(format('%s',[dbgrid1.Columns[p].Field.AsString]));
end;
Memo1.Lines.Add(l) ;
end;
end;
end;
end.
I tried to change the [dbgrid1.Columns[p].Field.AsString] so that it uses the text of the field but it doesn't work. Note-This is the template code that i hope to use
Is there an easier way without Sql to simply show a selected record in a memo?