2005. július 19., kedd
How to read a TMemoField into a TMemo
Problem/Question/Abstract:
I would like to read the lines from a memo field into my program using FieldByName().As. There does not seem to be any way to move the memo into a TString or TStringList or to access the memo field on a line by line basis. You can use a String or Variant. When you do this you get just one long composite string. Can you help?
Answer:
Almost every TStrings descendant has a LoadFromStream method:
procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField);
var
TB: TBlobStream;
begin
with TDataSource(Sender).DataSet do
if (State = dsBrowse) then
begin
TB := TBlobStream.create(FieldByName('Event_Description') as TBlobField, bmRead);
Memo1.Lines.LoadFromStream(TB);
{or ListBox1.items.LoadFromStream(TB);}
{or StringList1.LoadFromStream(TB);}
TB.Free;
end;
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése