Solved

Empty lines in memo

Posted on 2004-10-08
14
915 Views
Last Modified: 2012-05-05
Hi,

I have a problem with the memo component. When I add lines to it using memo1.lines.add('my line'); every new line has an empty line before it.

For example, if I do this:
memo1.lines.add('1');
memo1.lines.add('2');
memo1.lines.add('3');
I get this in the memo:
-----------------------------------
1                                            

2

3
-----------------------------------

What I want to know is how I can add those lines without having a space between them.
Any help is appreciated.

- MelchaS
0
Comment
Question by:MelchaS
  • 4
  • 3
  • 3
  • +4
14 Comments
 
LVL 6

Expert Comment

by:vadim_ti
ID: 12260317
in some place you add an empty line
otherwise you had to get
1
2
3
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12260408
procedure TFormMain.Button2Click(Sender: TObject);
begin
  Memo1.Clear;
  Memo1.lines.add('1');
  Memo1.lines.add('2');
  Memo1.lines.add('3');
end;

I got this in the memo:
-----------------------------------
1
2
3
-----------------------------------

but not what you describe .... Sorry
0
 
LVL 2

Expert Comment

by:-Karamja-
ID: 12260620
I also got the same as esoftbg,

What OS & Delphi version are you running?
Are you using custom style themes?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:tobjectpascal
ID: 12261044
i agree, something is adding the space..

what happens if you type in

Memo1.Text:='1'+#$0d+#$0a+'2'+#$0d+#$0a+'3';

do you still get the same problem?
0
 
LVL 7

Expert Comment

by:DavidBirch2dotCom
ID: 12261465
you've not managed to change the row height or the font size somewhere along the line have you ?

David
0
 

Author Comment

by:MelchaS
ID: 12261562
Sorry, I guess I wasnt specific enough.

The exact thing I do is this:

            Receive.Lines.Add('i:>->> ' + Send.Text);
            Receive.Lines.Add('o:<<-< Unknown command: ' + Send.Text);
            Send.Clear;

That adds the text in the Send memo to the Receive memo every time I press enter, and this is what I get if I do this a couple of times:

i:>->> fsdfds
o:<<-< Unknown command: fsdfds
i:>->>
gfdgfd
o:<<-< Unknown command:
gfdgfd

Somehow it adds everything on a new line...

I'm using Delphi 7 and WinXP, no custom themes...
0
 

Author Comment

by:MelchaS
ID: 12261576
This is if I do it more times:

i:>->> nvb
o:<<-< Unknown command: nvb
i:>->> hgvh

o:<<-< Unknown command: hgvh

i:>->>
gfdfd
o:<<-< Unknown command:
gfdfd
i:>->>
gdgfd
o:<<-< Unknown command:
gdgfd
i:>->> fsd'

o:<<-< Unknown command: fsd'

i:>->>
gdf
o:<<-< Unknown command:
gdf

What am I doing wrong?
0
 
LVL 2

Accepted Solution

by:
-Karamja- earned 50 total points
ID: 12261585
Sent.Text has a #13#10,

You will need to remove it,

Send.Text:= StringReplace(Send.Text, #13#10, '', [rfReplaceAll]);
0
 
LVL 7

Expert Comment

by:DavidBirch2dotCom
ID: 12261596
you could try *try*

replaceing any #13 's (returns) with nothing using something like

StringReplace(mystring, #13, '  ', [rfReplaceAll, rfIgnoreCase]);

David
0
 
LVL 7

Expert Comment

by:DavidBirch2dotCom
ID: 12261616
GRRRR I posted within in 60 seconds of you ! if this is the answer there should be a points split !

lol

David
0
 
LVL 2

Expert Comment

by:-Karamja-
ID: 12261622
Lol ;)
0
 

Author Comment

by:MelchaS
ID: 12262197
That works, thanks :)

Do you two agree on splitting the points, or should I give them to the first answer?
0
 
LVL 13

Expert Comment

by:BlackTigerX
ID: 12262924
that's a "quick" and dirty fix though...

do you have some code in the Memo events? like in the OnChange or something that would be adding those spaces?
0
 
LVL 7

Expert Comment

by:DavidBirch2dotCom
ID: 12267488
*sigh* it could so easily have been the other way around ;-p)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question