Solved

Empty lines in memo

Posted on 2004-10-08
14
892 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now