?
Solved

Empty lines in memo

Posted on 2004-10-08
14
Medium Priority
?
931 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
Independent Software Vendors: 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 200 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

Independent Software Vendors: 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!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

752 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