Board index » delphi » NEED HELP WITH MEMO FIELD !!please

NEED HELP WITH MEMO FIELD !!please

hi,

well , i have this problem with memo, in the file the memo contains 3
lines of text, so why does Mymemo.lines.count-1 returns 0 ? if i put a
memo component in the form and use it everything ok
the proporty lines.count-1 returns 3 witch is correct...

Please what is wrong with this code ?

    mymemo:=Tmemo.create(nil);
    try
      mymemo.text:=linhafactura.fieldbyname('Linha').AsString;
      for i:=0 to Mymemo.lines.count-1 do
          begin
            s:=mymemo.lines[i];
            StringGrid1.cells[1,r]:=s;
            r:=r+1;
          end;
    finally
      mymemo.free;
    end;

All i want to do is  read a memo field from a file and display it in a
string grid, if anyone knows another way please tell me.

Tnkx very much!
Kirk

 

Re:NEED HELP WITH MEMO FIELD !!please


Kirk,

I ran into this problem myself with D3, and worked around it by the
following:

Instead of:

Quote
>       mymemo.text:=linhafactura.fieldbyname('Linha').AsString;

Try:

myMemo.setTextBuf(PChar(FieldByName('Linha').asString));

I think there's a bug in D3's TMemo component...

Darren

Re:NEED HELP WITH MEMO FIELD !!please


Kirk,

Another solution to your problem might be to make sure that,
right after you create the memo, you set WordWrap to True;
unless you've done that (or your memo field in the database
contains carriage return/line feeds), you'll read in the entire
memo into a single line.

HTH

Ken
--
Ken White
kwh...@westelcom.com

Clipper Functions for Delphi
http://members.aol.com/clipfunc/

Quote
Kirk wrote:

> hi,

> well , i have this problem with memo, in the file the memo contains 3
> lines of text, so why does Mymemo.lines.count-1 returns 0 ? if i put a
> memo component in the form and use it everything ok
> the proporty lines.count-1 returns 3 witch is correct...

> Please what is wrong with this code ?

>     mymemo:=Tmemo.create(nil);
>     try
>       mymemo.text:=linhafactura.fieldbyname('Linha').AsString;
>       for i:=0 to Mymemo.lines.count-1 do
>           begin
>             s:=mymemo.lines[i];
>             StringGrid1.cells[1,r]:=s;
>             r:=r+1;
>           end;
>     finally
>       mymemo.free;
>     end;

> All i want to do is  read a memo field from a file and display it in a
> string grid, if anyone knows another way please tell me.

> Tnkx very much!
> Kirk

Other Threads