Solved

Empty lines in memo

Posted on 2004-10-08
14
927 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

705 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